Zelda Classic Coverage Report


Directory: src/
File: src/guys.cpp
Date: 2023-04-30 08:18:58
Exec Total Coverage
Lines: 8387 13260 63.3%
Functions: 322 426 75.6%
Branches: 6530 14558 44.9%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // guys.cc
6 //
7 // "Guys" code (and other related stuff) for zelda.cc
8 //
9 //--------------------------------------------------------
10
11 #include "precompiled.h" //always first
12
13 #include <string.h>
14 #include <stdio.h>
15 #include "base/zc_alleg.h"
16 #include "guys.h"
17
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 #include "zelda.h"
18 #include "base/zsys.h"
19 #include "maps.h"
20 #include "hero.h"
21 #include "subscr.h"
22 #include "ffscript.h"
23 #include "gamedata.h"
24 #include "defdata.h"
25 #include "zscriptversion.h"
26 #include "particles.h"
27 #include "base/zc_math.h"
28 #include "slopes.h"
29 extern particle_list particles;
30
31 extern FFScript FFCore;
32 extern word item_doscript[256];
33 extern refInfo itemScriptData[256];
34 extern int32_t item_stack[256][MAX_SCRIPT_REGISTERS];
35 extern ZModule zcm;
36 extern HeroClass Hero;
37 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
38 extern zinitdata zinit;
39
40 int32_t repaircharge=0;
41 bool adjustmagic=false;
42 bool learnslash=false;
43 int32_t wallm_load_clk=0;
44 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
45 int32_t vhead=0;
46 int32_t guycarryingitem=0;
47
48 char *guy_string[eMAXGUYS];
49
50 void never_return(int32_t index);
51 void playLevelMusic();
52
53 // If an enemy is this far out of the playing field, just remove it.
54 #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512)
55 //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767)
56 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
57 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
58
59 556243 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
60 {
61 556243 int32_t c = coord.getInt();
62
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 555976 times.
556243 if(nearest_half)
63 {
64
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 555976 times.
555976 if (c < 0)
65 c -= val / 2;
66 555976 else c += (val/2);
67 555976 }
68 556243 c -= c % val;
69 556243 coord = c;
70 556243 }
71
72 bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z)
73 {
74 return
75 (
76 (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2])
77 || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1])
78 || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1])
79 || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2])
80 || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1])
81 || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2])
82 );
83 }
84
85 namespace
86 {
87 int32_t trapConstantHorizontalID;
88 int32_t trapConstantVerticalID;
89 int32_t trapLOSHorizontalID;
90 int32_t trapLOSVerticalID;
91 int32_t trapLOS4WayID;
92
93 int32_t cornerTrapID;
94 int32_t centerTrapID;
95
96 int32_t rockID;
97 int32_t zoraID;
98 int32_t statueID;
99 }
100
101 97 void identifyCFEnemies()
102 {
103 97 trapConstantHorizontalID=-1;
104 97 trapConstantVerticalID=-1;
105 97 trapLOSHorizontalID=-1;
106 97 trapLOSVerticalID=-1;
107 97 trapLOS4WayID=-1;
108 97 cornerTrapID=-1;
109 97 centerTrapID=-1;
110 97 rockID=-1;
111 97 zoraID=-1;
112 97 statueID=-1;
113
114
2/2
✓ Branch 0 taken 49664 times.
✓ Branch 1 taken 97 times.
49761 for(int32_t i=0; i<eMAXGUYS; i++)
115 {
116
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 49568 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
49664 if((guysbuf[i].flags2&cmbflag_trph) && trapLOSHorizontalID==-1)
117 96 trapLOSHorizontalID=i;
118
4/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 49564 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 97 times.
49664 if((guysbuf[i].flags2&cmbflag_trpv) && trapLOSVerticalID==-1)
119 97 trapLOSVerticalID=i;
120
3/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 49567 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
49664 if((guysbuf[i].flags2&cmbflag_trp4) && trapLOS4WayID==-1)
121 97 trapLOS4WayID=i;
122
3/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 49567 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
49664 if((guysbuf[i].flags2&cmbflag_trplr) && trapConstantHorizontalID==-1)
123 97 trapConstantHorizontalID=i;
124
3/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 49567 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
49664 if((guysbuf[i].flags2&cmbflag_trpud) && trapConstantVerticalID==-1)
125 97 trapConstantVerticalID=i;
126
127
3/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 49567 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
49664 if((guysbuf[i].flags2&eneflag_trap) && cornerTrapID==-1)
128 97 cornerTrapID=i;
129
3/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 49567 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
49664 if((guysbuf[i].flags2&eneflag_trp2) && centerTrapID==-1)
130 97 centerTrapID=i;
131
132
3/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 49567 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
49664 if((guysbuf[i].flags2&eneflag_rock) && rockID==-1)
133 97 rockID=i;
134
3/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 49567 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
49664 if((guysbuf[i].flags2&eneflag_zora) && zoraID==-1)
135 97 zoraID=i;
136
137
4/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 49564 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 97 times.
49664 if((guysbuf[i].flags2 & eneflag_fire) && statueID==-1)
138 97 statueID=i;
139 49664 }
140 97 }
141
142 25 int32_t random_layer_enemy()
143 {
144 25 int32_t cnt=count_layer_enemies();
145
146
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(cnt==0)
147 {
148 return eNONE;
149 }
150
151 25 int32_t ret=zc_oldrand()%cnt;
152 25 cnt=0;
153
154
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 for(int32_t i=0; i<6; ++i)
155 {
156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(tmpscr->layermap[i]!=0)
157 {
158 25 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
159
160
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 for(int32_t j=0; j<10; ++j)
161 {
162
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
163 {
164
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 102 times.
127 if(cnt==ret)
165 {
166 25 return layerscreen->enemy[j];
167 }
168
169 102 ++cnt;
170 102 }
171 102 }
172 }
173 }
174
175 return eNONE;
176 25 }
177
178 39 int32_t count_layer_enemies()
179 {
180 39 int32_t cnt=0;
181
182
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 39 times.
273 for(int32_t i=0; i<6; ++i)
183 {
184
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 39 times.
234 if(tmpscr->layermap[i]!=0)
185 {
186 39 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
187
188
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 39 times.
429 for(int32_t j=0; j<10; ++j)
189 {
190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
390 if(layerscreen->enemy[j]!=0)
191 {
192 390 ++cnt;
193 390 }
194 390 }
195 39 }
196 234 }
197
198 39 return cnt;
199 }
200
201 134258 int32_t hero_on_wall()
202 {
203 134258 zfix lx = Hero.getX();
204 134258 zfix ly = Hero.getY();
205
206
207 //zprint2("hero_on_wall x is: %d\n", lx);
208 //zprint2("hero_on_wall y is: %d\n", ly);
209
210
4/4
✓ Branch 0 taken 125299 times.
✓ Branch 1 taken 8959 times.
✓ Branch 2 taken 4059 times.
✓ Branch 3 taken 121240 times.
134258 if(lx>=48 && lx<=192)
211 {
212
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 121096 times.
121240 if(ly==32) return up+1;
213
214
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 120972 times.
121096 if(ly==128) return down+1;
215 120972 }
216
217
4/4
✓ Branch 0 taken 124829 times.
✓ Branch 1 taken 9161 times.
✓ Branch 2 taken 10334 times.
✓ Branch 3 taken 114495 times.
133990 if(ly>=48 && ly<=112)
218 {
219
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 114367 times.
114495 if(lx==32) return left+1;
220
221
2/2
✓ Branch 0 taken 114307 times.
✓ Branch 1 taken 60 times.
114367 if(lx==208) return right+1;
222 114307 }
223
224 133802 return 0;
225 134258 }
226
227 663004 bool tooclose(int32_t x,int32_t y,int32_t d)
228 {
229
2/2
✓ Branch 0 taken 489865 times.
✓ Branch 1 taken 173139 times.
663004 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
230 }
231
232 1803542 bool enemy::overpit(enemy *e)
233 {
234
2/2
✓ Branch 0 taken 1800374 times.
✓ Branch 1 taken 22789760 times.
24590134 for ( int32_t q = 0; q < hxsz; ++q )
235 {
236
2/2
✓ Branch 0 taken 220125548 times.
✓ Branch 1 taken 22786592 times.
242912140 for ( int32_t q = 0; q < hysz; ++q )
237 {
238 //check every pixel of the hitbox
239
2/2
✓ Branch 0 taken 3168 times.
✓ Branch 1 taken 220122380 times.
220125548 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
240 {
241 //if the hitbox is over a pit, we can't land
242 3168 return true;
243 }
244 220122380 }
245 22786592 }
246 1800374 return false;
247 1803542 }
248
249 3387474 bool enemy::shadow_overpit(enemy *e)
250 {
251
2/2
✓ Branch 0 taken 3383622 times.
✓ Branch 1 taken 51693164 times.
55076786 for ( int32_t q = 0; q < hxsz; ++q )
252 {
253
2/2
✓ Branch 0 taken 778140099 times.
✓ Branch 1 taken 51689312 times.
829829411 for ( int32_t q = 0; q < hysz; ++q )
254 {
255 //check every pixel of the hitbox
256
2/2
✓ Branch 0 taken 3852 times.
✓ Branch 1 taken 778136247 times.
778140099 if ( ispitfall(x+q+hxofs, y+q+hyofs+hysz-2) )
257 {
258 //if the hitbox is over a pit, we can't land
259 3852 return true;
260 }
261 778136247 }
262 51689312 }
263 3383622 return false;
264 3387474 }
265
266 // Returns true iff a combo type or flag precludes enemy movement.
267 3224511 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
268 {
269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3224511 times.
3224511 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
270 3224511 int32_t c = COMBOTYPE(dx,dy);
271
4/4
✓ Branch 0 taken 2110730 times.
✓ Branch 1 taken 1113781 times.
✓ Branch 2 taken 469019 times.
✓ Branch 3 taken 644762 times.
4338292 bool pit_blocks = (!(moveflags & (FLAG_CAN_PITWALK|FLAG_ONLY_PITWALK)) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
272
3/6
✓ Branch 0 taken 1099981 times.
✓ Branch 1 taken 2124530 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1099981 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3224511 bool water_blocks = (!(moveflags & (FLAG_CAN_WATERWALK|FLAG_ONLY_WATERWALK|FLAG_ONLY_SHALLOW_WATERWALK)) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB) && get_bit(quest_rules,qr_DROWN));
273
4/6
✓ Branch 0 taken 1135400 times.
✓ Branch 1 taken 2089111 times.
✓ Branch 2 taken 1135400 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1135400 times.
✗ Branch 5 not taken.
6449537 return c==cPIT || c==cPITB || c==cPITC ||
274
4/6
✓ Branch 0 taken 1135400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1135400 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1046132 times.
✓ Branch 5 taken 89268 times.
1135400 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
275 // Block enemies type and block enemies flags
276
2/2
✓ Branch 0 taken 1134081 times.
✓ Branch 1 taken 1044813 times.
89268 combo_class_buf[c].block_enemies&1 ||
277
3/4
✓ Branch 0 taken 1134079 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1134079 times.
✗ Branch 3 not taken.
1134081 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
278
4/4
✓ Branch 0 taken 1133860 times.
✓ Branch 1 taken 219 times.
✓ Branch 2 taken 1133850 times.
✓ Branch 3 taken 10 times.
1134079 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
279 // Check for ladder-only combos which aren't dried water
280
4/4
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 1133256 times.
✓ Branch 2 taken 589 times.
✓ Branch 3 taken 5 times.
2267695 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
281 // Check for drownable water
282
4/4
✓ Branch 0 taken 102857 times.
✓ Branch 1 taken 1030988 times.
✓ Branch 2 taken 1900 times.
✓ Branch 3 taken 100957 times.
1133845 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false)));
283 1135915 }
284
285 // Returns true iff enemy is floating and blocked by a combo type or flag.
286 4024275 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
287 {
288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4024275 times.
4024275 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
289
4/4
✓ Branch 0 taken 2764890 times.
✓ Branch 1 taken 1259385 times.
✓ Branch 2 taken 1033771 times.
✓ Branch 3 taken 225614 times.
5283660 bool pit_blocks = (!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
290
3/4
✓ Branch 0 taken 2774894 times.
✓ Branch 1 taken 1249381 times.
✓ Branch 2 taken 1249381 times.
✗ Branch 3 not taken.
5273656 bool water_blocks = (!(moveflags & FLAG_CAN_WATERWALK) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB));
291
2/2
✓ Branch 0 taken 487591 times.
✓ Branch 1 taken 3536684 times.
7560959 return ((special==spw_floater)&&
292
2/2
✓ Branch 0 taken 3530573 times.
✓ Branch 1 taken 6111 times.
3536684 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
293
1/2
✓ Branch 0 taken 3530573 times.
✗ Branch 1 not taken.
3530573 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
294
1/2
✓ Branch 0 taken 3530573 times.
✗ Branch 1 not taken.
3530573 (MAPFLAG(dx,dy)==mfNOENEMY)||
295
1/2
✓ Branch 0 taken 3530573 times.
✗ Branch 1 not taken.
3530573 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
296
4/4
✓ Branch 0 taken 821159 times.
✓ Branch 1 taken 2709414 times.
✓ Branch 2 taken 1044 times.
✓ Branch 3 taken 820115 times.
7060102 (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) ||
297
2/2
✓ Branch 0 taken 2702951 times.
✓ Branch 1 taken 826578 times.
3529529 (pit_blocks && ispitfall(dx,dy))));
298 4024275 }
299 // Returns true iff a combo type or flag precludes enemy movement.
300 233302 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
301 {
302 233302 int32_t c = COMBOTYPE(dx,dy);
303 233302 bool pit_blocks = !(gd.moveflags & FLAG_CAN_PITWALK);
304
2/2
✓ Branch 0 taken 27325 times.
✓ Branch 1 taken 205977 times.
233302 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK) && get_bit(quest_rules,qr_DROWN);
305
3/6
✓ Branch 0 taken 233302 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 233302 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 233302 times.
✗ Branch 5 not taken.
885124 return c==cPIT || c==cPITB || c==cPITC ||
306
4/6
✓ Branch 0 taken 233302 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 233302 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 209267 times.
✓ Branch 5 taken 24035 times.
233302 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
307 // Block enemies type and block enemies flags
308
2/2
✓ Branch 0 taken 233295 times.
✓ Branch 1 taken 209260 times.
24035 combo_class_buf[c].block_enemies&1 ||
309
3/4
✓ Branch 0 taken 233176 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 233176 times.
✗ Branch 3 not taken.
233295 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
310
3/4
✓ Branch 0 taken 229708 times.
✓ Branch 1 taken 3468 times.
✓ Branch 2 taken 229708 times.
✗ Branch 3 not taken.
233176 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
311 // Check for ladder-only combos which aren't dried water
312
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 229677 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
459416 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
313 // Check for drownable water
314
4/4
✓ Branch 0 taken 32344 times.
✓ Branch 1 taken 197364 times.
✓ Branch 2 taken 24004 times.
✓ Branch 3 taken 8340 times.
229708 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)));
315 }
316
317 // Returns true iff enemy is floating and blocked by a combo type or flag.
318 114180 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
319 {
320
2/2
✓ Branch 0 taken 112869 times.
✓ Branch 1 taken 1311 times.
114180 bool pit_blocks = (!(gd.moveflags & FLAG_CAN_PITWALK) && !(gd.moveflags & FLAG_CAN_PITFALL));
321 114180 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK);
322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114180 times.
228360 return ((special==spw_floater)&&
323
1/2
✓ Branch 0 taken 114180 times.
✗ Branch 1 not taken.
114180 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
324
1/2
✓ Branch 0 taken 114180 times.
✗ Branch 1 not taken.
114180 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
325
1/2
✓ Branch 0 taken 114180 times.
✗ Branch 1 not taken.
114180 (MAPFLAG(dx,dy)==mfNOENEMY)||
326
1/2
✓ Branch 0 taken 114180 times.
✗ Branch 1 not taken.
114180 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
327
4/4
✓ Branch 0 taken 1311 times.
✓ Branch 1 taken 112869 times.
✓ Branch 2 taken 160 times.
✓ Branch 3 taken 1151 times.
228200 (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) ||
328
2/2
✓ Branch 0 taken 112869 times.
✓ Branch 1 taken 1151 times.
114020 (pit_blocks && ispitfall(dx,dy))));
329 }
330
331 /**********************************/
332 /******* Enemy Base Class *******/
333 /**********************************/
334
335 /* ROM data flags
336
337 */
338
339 eFire::eFire(eFire const & other, bool new_script_uid, bool clear_parent_script_UID):
340 //Struct Element Type Purpose
341 //sprite(other),
342 enemy(other),
343 clk4(other.clk4),
344 shield(other.shield)
345
346 {
347
348 //arrays
349
350 if(other.scrmem)
351 {
352 alloc_scriptmem();
353 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
354
355 scrmem->scriptData = other.scrmem->scriptData;
356 }
357 else scrmem = NULL;
358 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
359 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
360
361 for(int32_t i=0; i<edefLAST255; i++)
362 defense[i]=other.defense[i];
363 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
364 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
365
366 if(new_script_uid)
367 {
368 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
369 }
370 if(clear_parent_script_UID)
371 {
372 parent_script_UID = 0;
373 }
374 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
375 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
376
377 for ( int32_t q = 0; q < 8; q++ )
378 {
379 initD[q] = other.initD[q];
380 weap_initiald[q] = other.weap_initiald[q];
381 }
382 for ( int32_t q = 0; q < 2; q++ )
383 {
384 initA[q] = other.initA[q];
385 weap_initiala[q] = other.weap_initiala[q];
386 }
387 }
388
389 eOther::eOther(eOther const & other, bool new_script_uid, bool clear_parent_script_UID):
390 //Struct Element Type Purpose
391 //sprite(other),
392 enemy(other),
393 clk4(other.clk4),
394 shield(other.shield)
395
396 {
397
398 //arrays
399
400 if(other.scrmem)
401 {
402 alloc_scriptmem();
403 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
404
405 scrmem->scriptData = other.scrmem->scriptData;
406 }
407 else scrmem = NULL;
408 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
409 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
410
411 for(int32_t i=0; i<edefLAST255; i++)
412 defense[i]=other.defense[i];
413 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
414 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
415
416 if(new_script_uid)
417 {
418 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
419 }
420 if(clear_parent_script_UID)
421 {
422 parent_script_UID = 0;
423 }
424 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
425 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
426
427 for ( int32_t q = 0; q < 8; q++ )
428 {
429 initD[q] = other.initD[q];
430 weap_initiald[q] = other.weap_initiald[q];
431 }
432 for ( int32_t q = 0; q < 2; q++ )
433 {
434 initA[q] = other.initA[q];
435 weap_initiala[q] = other.weap_initiala[q];
436 }
437 }
438
439
440
441
442 eScript::eScript(eScript const & other, bool new_script_uid, bool clear_parent_script_UID):
443 //Struct Element Type Purpose
444 //sprite(other),
445 enemy(other),
446 clk4(other.clk4),
447 shield(other.shield)
448
449 {
450
451 //arrays
452
453 if(other.scrmem)
454 {
455 alloc_scriptmem();
456 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
457
458 scrmem->scriptData = other.scrmem->scriptData;
459 }
460 else scrmem = NULL;
461 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
462 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
463
464 for(int32_t i=0; i<edefLAST255; i++)
465 defense[i]=other.defense[i];
466 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
467 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
468
469 if(new_script_uid)
470 {
471 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
472 }
473 if(clear_parent_script_UID)
474 {
475 parent_script_UID = 0;
476 }
477 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
478 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
479
480 for ( int32_t q = 0; q < 8; q++ )
481 {
482 initD[q] = other.initD[q];
483 weap_initiald[q] = other.weap_initiald[q];
484 }
485 for ( int32_t q = 0; q < 2; q++ )
486 {
487 initA[q] = other.initA[q];
488 weap_initiala[q] = other.weap_initiala[q];
489 }
490 }
491
492 eFriendly::eFriendly(eFriendly const & other, bool new_script_uid, bool clear_parent_script_UID):
493 //Struct Element Type Purpose
494 //sprite(other),
495 enemy(other),
496 clk4(other.clk4),
497 shield(other.shield)
498
499 {
500
501 //arrays
502
503 if(other.scrmem)
504 {
505 alloc_scriptmem();
506 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
507
508 scrmem->scriptData = other.scrmem->scriptData;
509 }
510 else scrmem = NULL;
511 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
512 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
513
514 for(int32_t i=0; i<edefLAST255; i++)
515 defense[i]=other.defense[i];
516 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
517 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
518
519 if(new_script_uid)
520 {
521 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
522 }
523 if(clear_parent_script_UID)
524 {
525 parent_script_UID = 0;
526 }
527 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
528 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
529
530 for ( int32_t q = 0; q < 8; q++ )
531 {
532 initD[q] = other.initD[q];
533 weap_initiald[q] = other.weap_initiald[q];
534 }
535 for ( int32_t q = 0; q < 2; q++ )
536 {
537 initA[q] = other.initA[q];
538 weap_initiala[q] = other.weap_initiala[q];
539 }
540 }
541
542 eGhini::eGhini(eGhini const & other, bool new_script_uid, bool clear_parent_script_UID):
543 //Struct Element Type Purpose
544 //sprite(other),
545 enemy(other),
546 clk4(other.clk4),
547 ox(other.ox),
548 oy(other.oy),
549 c(other.c)
550
551 {
552
553 //arrays
554
555 if(other.scrmem)
556 {
557 alloc_scriptmem();
558 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
559
560 scrmem->scriptData = other.scrmem->scriptData;
561 }
562 else scrmem = NULL;
563 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
564 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
565
566 for(int32_t i=0; i<edefLAST255; i++)
567 defense[i]=other.defense[i];
568 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
569 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
570
571 if(new_script_uid)
572 {
573 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
574 }
575 if(clear_parent_script_UID)
576 {
577 parent_script_UID = 0;
578 }
579 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
580 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
581
582 for ( int32_t q = 0; q < 8; q++ )
583 {
584 initD[q] = other.initD[q];
585 weap_initiald[q] = other.weap_initiald[q];
586 }
587 for ( int32_t q = 0; q < 2; q++ )
588 {
589 initA[q] = other.initA[q];
590 weap_initiala[q] = other.weap_initiala[q];
591 }
592 }
593
594 eTektite::eTektite(eTektite const & other, bool new_script_uid, bool clear_parent_script_UID):
595 //Struct Element Type Purpose
596 //sprite(other),
597 enemy(other),
598 old_y(other.old_y),
599 clk2start(other.clk2start),
600 cstart(other.cstart),
601 c(other.c)
602
603 {
604
605 //arrays
606
607 if(other.scrmem)
608 {
609 alloc_scriptmem();
610 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
611
612 scrmem->scriptData = other.scrmem->scriptData;
613 }
614 else scrmem = NULL;
615 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
616 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
617
618 for(int32_t i=0; i<edefLAST255; i++)
619 defense[i]=other.defense[i];
620 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
621 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
622
623 if(new_script_uid)
624 {
625 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
626 }
627 if(clear_parent_script_UID)
628 {
629 parent_script_UID = 0;
630 }
631 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
632 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
633
634 for ( int32_t q = 0; q < 8; q++ )
635 {
636 initD[q] = other.initD[q];
637 weap_initiald[q] = other.weap_initiald[q];
638 }
639 for ( int32_t q = 0; q < 2; q++ )
640 {
641 initA[q] = other.initA[q];
642 weap_initiala[q] = other.weap_initiala[q];
643 }
644 }
645
646 eItemFairy::eItemFairy(eItemFairy const & other, bool new_script_uid, bool clear_parent_script_UID):
647 //Struct Element Type Purpose
648 //sprite(other),
649 enemy(other)
650 {
651
652 //arrays
653
654 if(other.scrmem)
655 {
656 alloc_scriptmem();
657 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
658
659 scrmem->scriptData = other.scrmem->scriptData;
660 }
661 else scrmem = NULL;
662 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
663 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
664
665 for(int32_t i=0; i<edefLAST255; i++)
666 defense[i]=other.defense[i];
667 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
668 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
669
670 if(new_script_uid)
671 {
672 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
673 }
674 if(clear_parent_script_UID)
675 {
676 parent_script_UID = 0;
677 }
678 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
679 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
680
681 for ( int32_t q = 0; q < 8; q++ )
682 {
683 initD[q] = other.initD[q];
684 weap_initiald[q] = other.weap_initiald[q];
685 }
686 for ( int32_t q = 0; q < 2; q++ )
687 {
688 initA[q] = other.initA[q];
689 weap_initiala[q] = other.weap_initiala[q];
690 }
691 }
692
693 ePeahat::ePeahat(ePeahat const & other, bool new_script_uid, bool clear_parent_script_UID):
694 //Struct Element Type Purpose
695 //sprite(other),
696 enemy(other),
697 ox(other.ox),
698 oy(other.oy),
699 c(other.c)
700 {
701
702 //arrays
703
704 if(other.scrmem)
705 {
706 alloc_scriptmem();
707 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
708
709 scrmem->scriptData = other.scrmem->scriptData;
710 }
711 else scrmem = NULL;
712 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
713 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
714
715 for(int32_t i=0; i<edefLAST255; i++)
716 defense[i]=other.defense[i];
717 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
718 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
719
720 if(new_script_uid)
721 {
722 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
723 }
724 if(clear_parent_script_UID)
725 {
726 parent_script_UID = 0;
727 }
728 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
729 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
730
731 for ( int32_t q = 0; q < 8; q++ )
732 {
733 initD[q] = other.initD[q];
734 weap_initiald[q] = other.weap_initiald[q];
735 }
736 for ( int32_t q = 0; q < 2; q++ )
737 {
738 initA[q] = other.initA[q];
739 weap_initiala[q] = other.weap_initiala[q];
740 }
741 }
742
743 eLeever::eLeever(eLeever const & other, bool new_script_uid, bool clear_parent_script_UID):
744 //Struct Element Type Purpose
745 //sprite(other),
746 enemy(other),
747 temprule(other.temprule)
748 {
749
750 //arrays
751
752 if(other.scrmem)
753 {
754 alloc_scriptmem();
755 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
756
757 scrmem->scriptData = other.scrmem->scriptData;
758 }
759 else scrmem = NULL;
760 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
761 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
762
763 for(int32_t i=0; i<edefLAST255; i++)
764 defense[i]=other.defense[i];
765 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
766 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
767
768 if(new_script_uid)
769 {
770 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
771 }
772 if(clear_parent_script_UID)
773 {
774 parent_script_UID = 0;
775 }
776 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
777 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
778
779 for ( int32_t q = 0; q < 8; q++ )
780 {
781 initD[q] = other.initD[q];
782 weap_initiald[q] = other.weap_initiald[q];
783 }
784 for ( int32_t q = 0; q < 2; q++ )
785 {
786 initA[q] = other.initA[q];
787 weap_initiala[q] = other.weap_initiala[q];
788 }
789 }
790
791 eWallM::eWallM(eWallM const & other, bool new_script_uid, bool clear_parent_script_UID):
792 //Struct Element Type Purpose
793 //sprite(other),
794 enemy(other)
795 {
796
797 //arrays
798
799 if(other.scrmem)
800 {
801 alloc_scriptmem();
802 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
803
804 scrmem->scriptData = other.scrmem->scriptData;
805 }
806 else scrmem = NULL;
807 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
808 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
809
810 for(int32_t i=0; i<edefLAST255; i++)
811 defense[i]=other.defense[i];
812 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
813 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
814
815 if(new_script_uid)
816 {
817 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
818 }
819 if(clear_parent_script_UID)
820 {
821 parent_script_UID = 0;
822 }
823 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
824 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
825
826 for ( int32_t q = 0; q < 8; q++ )
827 {
828 initD[q] = other.initD[q];
829 weap_initiald[q] = other.weap_initiald[q];
830 }
831 for ( int32_t q = 0; q < 2; q++ )
832 {
833 initA[q] = other.initA[q];
834 weap_initiala[q] = other.weap_initiala[q];
835 }
836 }
837
838 eStalfos::eStalfos(eStalfos const & other, bool new_script_uid, bool clear_parent_script_UID):
839 //Struct Element Type Purpose
840 //sprite(other),
841 enemy(other),
842 clk4(other.clk4),
843 clk5(other.clk5),
844 fired(other.fired),
845 shield(other.shield),
846 dashing(other.dashing),
847 multishot(other.multishot),
848 fy(other.fy),
849 shadowdistance(other.shadowdistance)
850 {
851
852 //arrays
853
854 if(other.scrmem)
855 {
856 alloc_scriptmem();
857 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
858
859 scrmem->scriptData = other.scrmem->scriptData;
860 }
861 else scrmem = NULL;
862 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
863 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
864
865 for(int32_t i=0; i<edefLAST255; i++)
866 defense[i]=other.defense[i];
867 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
868 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
869
870 if(new_script_uid)
871 {
872 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
873 }
874 if(clear_parent_script_UID)
875 {
876 parent_script_UID = 0;
877 }
878 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
879 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
880
881 for ( int32_t q = 0; q < 8; q++ )
882 {
883 initD[q] = other.initD[q];
884 weap_initiald[q] = other.weap_initiald[q];
885 }
886 for ( int32_t q = 0; q < 2; q++ )
887 {
888 initA[q] = other.initA[q];
889 weap_initiala[q] = other.weap_initiala[q];
890 }
891 }
892
893 eZora::eZora(eZora const & other, bool new_script_uid, bool clear_parent_script_UID):
894 //Struct Element Type Purpose
895 //sprite(other),
896 enemy(other)
897 {
898
899 //arrays
900
901 if(other.scrmem)
902 {
903 alloc_scriptmem();
904 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
905
906 scrmem->scriptData = other.scrmem->scriptData;
907 }
908 else scrmem = NULL;
909 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
910 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
911
912 for(int32_t i=0; i<edefLAST255; i++)
913 defense[i]=other.defense[i];
914 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
915 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
916
917 if(new_script_uid)
918 {
919 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
920 }
921 if(clear_parent_script_UID)
922 {
923 parent_script_UID = 0;
924 }
925 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
926 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
927
928 for ( int32_t q = 0; q < 8; q++ )
929 {
930 initD[q] = other.initD[q];
931 weap_initiald[q] = other.weap_initiald[q];
932 }
933 for ( int32_t q = 0; q < 2; q++ )
934 {
935 initA[q] = other.initA[q];
936 weap_initiala[q] = other.weap_initiala[q];
937 }
938 }
939
940 eSpinTile::eSpinTile(eSpinTile const & other, bool new_script_uid, bool clear_parent_script_UID):
941 //Struct Element Type Purpose
942 //sprite(other),
943 enemy(other)
944 {
945
946 //arrays
947
948 if(other.scrmem)
949 {
950 alloc_scriptmem();
951 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
952
953 scrmem->scriptData = other.scrmem->scriptData;
954 }
955 else scrmem = NULL;
956 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
957 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
958
959 for(int32_t i=0; i<edefLAST255; i++)
960 defense[i]=other.defense[i];
961 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
962 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
963
964 if(new_script_uid)
965 {
966 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
967 }
968 if(clear_parent_script_UID)
969 {
970 parent_script_UID = 0;
971 }
972 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
973 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
974
975 for ( int32_t q = 0; q < 8; q++ )
976 {
977 initD[q] = other.initD[q];
978 weap_initiald[q] = other.weap_initiald[q];
979 }
980 for ( int32_t q = 0; q < 2; q++ )
981 {
982 initA[q] = other.initA[q];
983 weap_initiala[q] = other.weap_initiala[q];
984 }
985 }
986
987 eNPC::eNPC(eNPC const & other, bool new_script_uid, bool clear_parent_script_UID):
988 //Struct Element Type Purpose
989 //sprite(other),
990 enemy(other)
991 {
992
993 //arrays
994
995 if(other.scrmem)
996 {
997 alloc_scriptmem();
998 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
999
1000 scrmem->scriptData = other.scrmem->scriptData;
1001 }
1002 else scrmem = NULL;
1003 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1004 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1005
1006 for(int32_t i=0; i<edefLAST255; i++)
1007 defense[i]=other.defense[i];
1008 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1009 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1010
1011 if(new_script_uid)
1012 {
1013 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1014 }
1015 if(clear_parent_script_UID)
1016 {
1017 parent_script_UID = 0;
1018 }
1019 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1020 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1021
1022 for ( int32_t q = 0; q < 8; q++ )
1023 {
1024 initD[q] = other.initD[q];
1025 weap_initiald[q] = other.weap_initiald[q];
1026 }
1027 for ( int32_t q = 0; q < 2; q++ )
1028 {
1029 initA[q] = other.initA[q];
1030 weap_initiala[q] = other.weap_initiala[q];
1031 }
1032 }
1033
1034 eTrigger::eTrigger(eTrigger const & other, bool new_script_uid, bool clear_parent_script_UID):
1035 //Struct Element Type Purpose
1036 //sprite(other),
1037 enemy(other)
1038 {
1039
1040 //arrays
1041
1042 if(other.scrmem)
1043 {
1044 alloc_scriptmem();
1045 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1046
1047 scrmem->scriptData = other.scrmem->scriptData;
1048 }
1049 else scrmem = NULL;
1050 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1051 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1052
1053 for(int32_t i=0; i<edefLAST255; i++)
1054 defense[i]=other.defense[i];
1055 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1056 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1057
1058 if(new_script_uid)
1059 {
1060 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1061 }
1062 if(clear_parent_script_UID)
1063 {
1064 parent_script_UID = 0;
1065 }
1066 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1067 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1068
1069 for ( int32_t q = 0; q < 8; q++ )
1070 {
1071 initD[q] = other.initD[q];
1072 weap_initiald[q] = other.weap_initiald[q];
1073 }
1074 for ( int32_t q = 0; q < 2; q++ )
1075 {
1076 initA[q] = other.initA[q];
1077 weap_initiala[q] = other.weap_initiala[q];
1078 }
1079 }
1080
1081 eProjectile::eProjectile(eProjectile const & other, bool new_script_uid, bool clear_parent_script_UID):
1082 //Struct Element Type Purpose
1083 //sprite(other),
1084 enemy(other),
1085 minRange(other.minRange)
1086 {
1087
1088 //arrays
1089
1090 if(other.scrmem)
1091 {
1092 alloc_scriptmem();
1093 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1094
1095 scrmem->scriptData = other.scrmem->scriptData;
1096 }
1097 else scrmem = NULL;
1098 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1099 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1100
1101 for(int32_t i=0; i<edefLAST255; i++)
1102 defense[i]=other.defense[i];
1103 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1104 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1105
1106 if(new_script_uid)
1107 {
1108 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1109 }
1110 if(clear_parent_script_UID)
1111 {
1112 parent_script_UID = 0;
1113 }
1114 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1115 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1116
1117 for ( int32_t q = 0; q < 8; q++ )
1118 {
1119 initD[q] = other.initD[q];
1120 weap_initiald[q] = other.weap_initiald[q];
1121 }
1122 for ( int32_t q = 0; q < 2; q++ )
1123 {
1124 initA[q] = other.initA[q];
1125 weap_initiala[q] = other.weap_initiala[q];
1126 }
1127 }
1128
1129 eBoulder::eBoulder(eBoulder const & other, bool new_script_uid, bool clear_parent_script_UID):
1130 //Struct Element Type Purpose
1131 //sprite(other),
1132 enemy(other)
1133 {
1134
1135 //arrays
1136
1137 if(other.scrmem)
1138 {
1139 alloc_scriptmem();
1140 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1141
1142 scrmem->scriptData = other.scrmem->scriptData;
1143 }
1144 else scrmem = NULL;
1145 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1146 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1147
1148 for(int32_t i=0; i<edefLAST255; i++)
1149 defense[i]=other.defense[i];
1150 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1151 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1152
1153 if(new_script_uid)
1154 {
1155 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1156 }
1157 if(clear_parent_script_UID)
1158 {
1159 parent_script_UID = 0;
1160 }
1161 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1162 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1163
1164 for ( int32_t q = 0; q < 8; q++ )
1165 {
1166 initD[q] = other.initD[q];
1167 weap_initiald[q] = other.weap_initiald[q];
1168 }
1169 for ( int32_t q = 0; q < 2; q++ )
1170 {
1171 initA[q] = other.initA[q];
1172 weap_initiala[q] = other.weap_initiala[q];
1173 }
1174 }
1175
1176 eRock::eRock(eRock const & other, bool new_script_uid, bool clear_parent_script_UID):
1177 //Struct Element Type Purpose
1178 //sprite(other),
1179 enemy(other)
1180 {
1181
1182 //arrays
1183
1184 if(other.scrmem)
1185 {
1186 alloc_scriptmem();
1187 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1188
1189 scrmem->scriptData = other.scrmem->scriptData;
1190 }
1191 else scrmem = NULL;
1192 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1193 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1194
1195 for(int32_t i=0; i<edefLAST255; i++)
1196 defense[i]=other.defense[i];
1197 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1198 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1199
1200 if(new_script_uid)
1201 {
1202 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1203 }
1204 if(clear_parent_script_UID)
1205 {
1206 parent_script_UID = 0;
1207 }
1208 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1209 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1210
1211 for ( int32_t q = 0; q < 8; q++ )
1212 {
1213 initD[q] = other.initD[q];
1214 weap_initiald[q] = other.weap_initiald[q];
1215 }
1216 for ( int32_t q = 0; q < 2; q++ )
1217 {
1218 initA[q] = other.initA[q];
1219 weap_initiala[q] = other.weap_initiala[q];
1220 }
1221 }
1222
1223 eTrap2::eTrap2(eTrap2 const & other, bool new_script_uid, bool clear_parent_script_UID):
1224 //Struct Element Type Purpose
1225 //sprite(other),
1226 enemy(other)
1227 {
1228
1229 //arrays
1230
1231 if(other.scrmem)
1232 {
1233 alloc_scriptmem();
1234 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1235
1236 scrmem->scriptData = other.scrmem->scriptData;
1237 }
1238 else scrmem = NULL;
1239 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1240 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1241
1242 for(int32_t i=0; i<edefLAST255; i++)
1243 defense[i]=other.defense[i];
1244 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1245 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1246
1247 if(new_script_uid)
1248 {
1249 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1250 }
1251 if(clear_parent_script_UID)
1252 {
1253 parent_script_UID = 0;
1254 }
1255 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1256 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1257
1258 for ( int32_t q = 0; q < 8; q++ )
1259 {
1260 initD[q] = other.initD[q];
1261 weap_initiald[q] = other.weap_initiald[q];
1262 }
1263 for ( int32_t q = 0; q < 2; q++ )
1264 {
1265 initA[q] = other.initA[q];
1266 weap_initiala[q] = other.weap_initiala[q];
1267 }
1268 }
1269
1270 eTrap::eTrap(eTrap const & other, bool new_script_uid, bool clear_parent_script_UID):
1271 //Struct Element Type Purpose
1272 //sprite(other),
1273 enemy(other),
1274 ox(other.ox),
1275 oy(other.oy)
1276 {
1277
1278 //arrays
1279
1280 if(other.scrmem)
1281 {
1282 alloc_scriptmem();
1283 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1284
1285 scrmem->scriptData = other.scrmem->scriptData;
1286 }
1287 else scrmem = NULL;
1288 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1289 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1290
1291 for(int32_t i=0; i<edefLAST255; i++)
1292 defense[i]=other.defense[i];
1293 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1294 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1295
1296 if(new_script_uid)
1297 {
1298 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1299 }
1300 if(clear_parent_script_UID)
1301 {
1302 parent_script_UID = 0;
1303 }
1304 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1305 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1306
1307 for ( int32_t q = 0; q < 8; q++ )
1308 {
1309 initD[q] = other.initD[q];
1310 weap_initiald[q] = other.weap_initiald[q];
1311 }
1312 for ( int32_t q = 0; q < 2; q++ )
1313 {
1314 initA[q] = other.initA[q];
1315 weap_initiala[q] = other.weap_initiala[q];
1316 }
1317 }
1318
1319
1320
1321
1322 eKeese::eKeese(eKeese const & other, bool new_script_uid, bool clear_parent_script_UID):
1323 //Struct Element Type Purpose
1324 //sprite(other),
1325 enemy(other),
1326 ox(other.ox),
1327 c(other.c),
1328 clk4(other.clk4),
1329 oy(other.oy)
1330 {
1331
1332 //arrays
1333
1334 if(other.scrmem)
1335 {
1336 alloc_scriptmem();
1337 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1338
1339 scrmem->scriptData = other.scrmem->scriptData;
1340 }
1341 else scrmem = NULL;
1342 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1343 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1344
1345 for(int32_t i=0; i<edefLAST255; i++)
1346 defense[i]=other.defense[i];
1347 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1348 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1349
1350 if(new_script_uid)
1351 {
1352 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1353 }
1354 if(clear_parent_script_UID)
1355 {
1356 parent_script_UID = 0;
1357 }
1358 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1359 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1360
1361 for ( int32_t q = 0; q < 8; q++ )
1362 {
1363 initD[q] = other.initD[q];
1364 weap_initiald[q] = other.weap_initiald[q];
1365 }
1366 for ( int32_t q = 0; q < 2; q++ )
1367 {
1368 initA[q] = other.initA[q];
1369 weap_initiala[q] = other.weap_initiala[q];
1370 }
1371 }
1372
1373 eWizzrobe::eWizzrobe(eWizzrobe const & other, bool new_script_uid, bool clear_parent_script_UID):
1374 //Struct Element Type Purpose
1375 //sprite(other),
1376 enemy(other),
1377 charging(other.charging),
1378 firing(other.firing),
1379 fclk(other.fclk)
1380 {
1381
1382 //arrays
1383
1384 if(other.scrmem)
1385 {
1386 alloc_scriptmem();
1387 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1388
1389 scrmem->scriptData = other.scrmem->scriptData;
1390 }
1391 else scrmem = NULL;
1392 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1393 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1394
1395 for(int32_t i=0; i<edefLAST255; i++)
1396 defense[i]=other.defense[i];
1397 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1398 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1399
1400 if(new_script_uid)
1401 {
1402 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1403 }
1404 if(clear_parent_script_UID)
1405 {
1406 parent_script_UID = 0;
1407 }
1408 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1409 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1410
1411 for ( int32_t q = 0; q < 8; q++ )
1412 {
1413 initD[q] = other.initD[q];
1414 weap_initiald[q] = other.weap_initiald[q];
1415 }
1416 for ( int32_t q = 0; q < 2; q++ )
1417 {
1418 initA[q] = other.initA[q];
1419 weap_initiala[q] = other.weap_initiala[q];
1420 }
1421 }
1422
1423 eDodongo::eDodongo(eDodongo const & other, bool new_script_uid, bool clear_parent_script_UID):
1424 //Struct Element Type Purpose
1425 //sprite(other),
1426 enemy(other)
1427 {
1428
1429 //arrays
1430
1431 if(other.scrmem)
1432 {
1433 alloc_scriptmem();
1434 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1435
1436 scrmem->scriptData = other.scrmem->scriptData;
1437 }
1438 else scrmem = NULL;
1439 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1440 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1441
1442 for(int32_t i=0; i<edefLAST255; i++)
1443 defense[i]=other.defense[i];
1444 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1445 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1446
1447 if(new_script_uid)
1448 {
1449 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1450 }
1451 if(clear_parent_script_UID)
1452 {
1453 parent_script_UID = 0;
1454 }
1455 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1456 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1457
1458 for ( int32_t q = 0; q < 8; q++ )
1459 {
1460 initD[q] = other.initD[q];
1461 weap_initiald[q] = other.weap_initiald[q];
1462 }
1463 for ( int32_t q = 0; q < 2; q++ )
1464 {
1465 initA[q] = other.initA[q];
1466 weap_initiala[q] = other.weap_initiala[q];
1467 }
1468 }
1469
1470 eDodongo2::eDodongo2(eDodongo2 const & other, bool new_script_uid, bool clear_parent_script_UID):
1471 //Struct Element Type Purpose
1472 //sprite(other),
1473 enemy(other),
1474 previous_dir(other.previous_dir)
1475 {
1476
1477 //arrays
1478
1479 if(other.scrmem)
1480 {
1481 alloc_scriptmem();
1482 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1483
1484 scrmem->scriptData = other.scrmem->scriptData;
1485 }
1486 else scrmem = NULL;
1487 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1488 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1489
1490 for(int32_t i=0; i<edefLAST255; i++)
1491 defense[i]=other.defense[i];
1492 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1493 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1494
1495 if(new_script_uid)
1496 {
1497 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1498 }
1499 if(clear_parent_script_UID)
1500 {
1501 parent_script_UID = 0;
1502 }
1503 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1504 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1505
1506 for ( int32_t q = 0; q < 8; q++ )
1507 {
1508 initD[q] = other.initD[q];
1509 weap_initiald[q] = other.weap_initiald[q];
1510 }
1511 for ( int32_t q = 0; q < 2; q++ )
1512 {
1513 initA[q] = other.initA[q];
1514 weap_initiala[q] = other.weap_initiala[q];
1515 }
1516 }
1517
1518 eAquamentus::eAquamentus(eAquamentus const & other, bool new_script_uid, bool clear_parent_script_UID):
1519 //Struct Element Type Purpose
1520 //sprite(other),
1521 enemy(other),
1522 fbx(other.fbx),
1523 clk4(other.clk4)
1524 {
1525
1526 //arrays
1527
1528 if(other.scrmem)
1529 {
1530 alloc_scriptmem();
1531 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1532
1533 scrmem->scriptData = other.scrmem->scriptData;
1534 }
1535 else scrmem = NULL;
1536 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1537 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1538
1539 for(int32_t i=0; i<edefLAST255; i++)
1540 defense[i]=other.defense[i];
1541 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1542 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1543
1544 if(new_script_uid)
1545 {
1546 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1547 }
1548 if(clear_parent_script_UID)
1549 {
1550 parent_script_UID = 0;
1551 }
1552 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1553 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1554
1555 for ( int32_t q = 0; q < 8; q++ )
1556 {
1557 initD[q] = other.initD[q];
1558 weap_initiald[q] = other.weap_initiald[q];
1559 }
1560 for ( int32_t q = 0; q < 2; q++ )
1561 {
1562 initA[q] = other.initA[q];
1563 weap_initiala[q] = other.weap_initiala[q];
1564 }
1565 }
1566
1567 eGohma::eGohma(eGohma const & other, bool new_script_uid, bool clear_parent_script_UID):
1568 //Struct Element Type Purpose
1569 //sprite(other),
1570 enemy(other),
1571 clk4(other.clk4)
1572 {
1573
1574 //arrays
1575
1576 if(other.scrmem)
1577 {
1578 alloc_scriptmem();
1579 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1580
1581 scrmem->scriptData = other.scrmem->scriptData;
1582 }
1583 else scrmem = NULL;
1584 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1585 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1586
1587 for(int32_t i=0; i<edefLAST255; i++)
1588 defense[i]=other.defense[i];
1589 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1590 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1591
1592 if(new_script_uid)
1593 {
1594 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1595 }
1596 if(clear_parent_script_UID)
1597 {
1598 parent_script_UID = 0;
1599 }
1600 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1601 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1602
1603 for ( int32_t q = 0; q < 8; q++ )
1604 {
1605 initD[q] = other.initD[q];
1606 weap_initiald[q] = other.weap_initiald[q];
1607 }
1608 for ( int32_t q = 0; q < 2; q++ )
1609 {
1610 initA[q] = other.initA[q];
1611 weap_initiala[q] = other.weap_initiala[q];
1612 }
1613 }
1614
1615 eLilDig::eLilDig(eLilDig const & other, bool new_script_uid, bool clear_parent_script_UID):
1616 //Struct Element Type Purpose
1617 //sprite(other),
1618 enemy(other)
1619 {
1620
1621 //arrays
1622
1623 if(other.scrmem)
1624 {
1625 alloc_scriptmem();
1626 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1627
1628 scrmem->scriptData = other.scrmem->scriptData;
1629 }
1630 else scrmem = NULL;
1631 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1632 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1633
1634 for(int32_t i=0; i<edefLAST255; i++)
1635 defense[i]=other.defense[i];
1636 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1637 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1638
1639 if(new_script_uid)
1640 {
1641 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1642 }
1643 if(clear_parent_script_UID)
1644 {
1645 parent_script_UID = 0;
1646 }
1647 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1648 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1649
1650 for ( int32_t q = 0; q < 8; q++ )
1651 {
1652 initD[q] = other.initD[q];
1653 weap_initiald[q] = other.weap_initiald[q];
1654 }
1655 for ( int32_t q = 0; q < 2; q++ )
1656 {
1657 initA[q] = other.initA[q];
1658 weap_initiala[q] = other.weap_initiala[q];
1659 }
1660 }
1661
1662 eBigDig::eBigDig(eBigDig const & other, bool new_script_uid, bool clear_parent_script_UID):
1663 //Struct Element Type Purpose
1664 //sprite(other),
1665 enemy(other)
1666 {
1667
1668 //arrays
1669
1670 if(other.scrmem)
1671 {
1672 alloc_scriptmem();
1673 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1674
1675 scrmem->scriptData = other.scrmem->scriptData;
1676 }
1677 else scrmem = NULL;
1678 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1679 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1680
1681 for(int32_t i=0; i<edefLAST255; i++)
1682 defense[i]=other.defense[i];
1683 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1684 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1685
1686 if(new_script_uid)
1687 {
1688 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1689 }
1690 if(clear_parent_script_UID)
1691 {
1692 parent_script_UID = 0;
1693 }
1694 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1695 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1696
1697 for ( int32_t q = 0; q < 8; q++ )
1698 {
1699 initD[q] = other.initD[q];
1700 weap_initiald[q] = other.weap_initiald[q];
1701 }
1702 for ( int32_t q = 0; q < 2; q++ )
1703 {
1704 initA[q] = other.initA[q];
1705 weap_initiala[q] = other.weap_initiala[q];
1706 }
1707 }
1708
1709 eGanon::eGanon(eGanon const & other, bool new_script_uid, bool clear_parent_script_UID):
1710 //Struct Element Type Purpose
1711 //sprite(other),
1712 enemy(other),
1713 Stunclk(other.Stunclk)
1714
1715 {
1716
1717 //arrays
1718
1719 if(other.scrmem)
1720 {
1721 alloc_scriptmem();
1722 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1723
1724 scrmem->scriptData = other.scrmem->scriptData;
1725 }
1726 else scrmem = NULL;
1727 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1728 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1729
1730 for(int32_t i=0; i<edefLAST255; i++)
1731 defense[i]=other.defense[i];
1732 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1733 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1734
1735 if(new_script_uid)
1736 {
1737 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1738 }
1739 if(clear_parent_script_UID)
1740 {
1741 parent_script_UID = 0;
1742 }
1743 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1744 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1745
1746 for ( int32_t q = 0; q < 8; q++ )
1747 {
1748 initD[q] = other.initD[q];
1749 weap_initiald[q] = other.weap_initiald[q];
1750 }
1751 for ( int32_t q = 0; q < 2; q++ )
1752 {
1753 initA[q] = other.initA[q];
1754 weap_initiala[q] = other.weap_initiala[q];
1755 }
1756 }
1757
1758 eMoldorm::eMoldorm(eMoldorm const & other, bool new_script_uid, bool clear_parent_script_UID):
1759 //Struct Element Type Purpose
1760 //sprite(other),
1761 enemy(other),
1762 segcnt(other.segcnt),
1763 segid(other.segid)
1764
1765 {
1766
1767 //arrays
1768
1769 if(other.scrmem)
1770 {
1771 alloc_scriptmem();
1772 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1773
1774 scrmem->scriptData = other.scrmem->scriptData;
1775 }
1776 else scrmem = NULL;
1777 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1778 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1779
1780 for(int32_t i=0; i<edefLAST255; i++)
1781 defense[i]=other.defense[i];
1782 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1783 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1784
1785 if(new_script_uid)
1786 {
1787 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1788 }
1789 if(clear_parent_script_UID)
1790 {
1791 parent_script_UID = 0;
1792 }
1793 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1794 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1795
1796 for ( int32_t q = 0; q < 8; q++ )
1797 {
1798 initD[q] = other.initD[q];
1799 weap_initiald[q] = other.weap_initiald[q];
1800 }
1801 for ( int32_t q = 0; q < 2; q++ )
1802 {
1803 initA[q] = other.initA[q];
1804 weap_initiala[q] = other.weap_initiala[q];
1805 }
1806 }
1807
1808 esMoldorm::esMoldorm(esMoldorm const & other, bool new_script_uid, bool clear_parent_script_UID):
1809 //Struct Element Type Purpose
1810 //sprite(other),
1811 enemy(other),
1812 parentclk(other.parentclk)
1813 {
1814
1815 //arrays
1816
1817 if(other.scrmem)
1818 {
1819 alloc_scriptmem();
1820 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1821
1822 scrmem->scriptData = other.scrmem->scriptData;
1823 }
1824 else scrmem = NULL;
1825 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1826 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1827
1828 for(int32_t i=0; i<edefLAST255; i++)
1829 defense[i]=other.defense[i];
1830 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1831 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1832
1833 if(new_script_uid)
1834 {
1835 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1836 }
1837 if(clear_parent_script_UID)
1838 {
1839 parent_script_UID = 0;
1840 }
1841 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1842 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1843
1844 for ( int32_t q = 0; q < 8; q++ )
1845 {
1846 initD[q] = other.initD[q];
1847 weap_initiald[q] = other.weap_initiald[q];
1848 }
1849 for ( int32_t q = 0; q < 2; q++ )
1850 {
1851 initA[q] = other.initA[q];
1852 weap_initiala[q] = other.weap_initiala[q];
1853 }
1854 }
1855 /*
1856 eManhandla::eManhandla(eManhandla const & other, bool new_script_uid, bool clear_parent_script_UID):
1857 //Struct Element Type Purpose
1858 //sprite(other),
1859 enemy(other),
1860 armcnt(armcnt),
1861 adjusted(adjusted),
1862 arm[0](arm[0]),
1863 arm[1](arm[1]),
1864 arm[2](arm[2]),
1865 arm[3](arm[3]),
1866 arm[4](arm[4]),
1867 arm[5](arm[5]),
1868 arm[6](arm[6]),
1869 arm[7](arm[7])
1870 {
1871
1872 //arrays
1873 if(other.scrmem)
1874 {
1875 alloc_scriptmem();
1876 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1877
1878 scrmem->scriptData = other.scrmem->scriptData;
1879 }
1880 else scrmem = NULL;
1881 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1882 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1883
1884 for(int32_t i=0; i<edefLAST255; i++)
1885 defense[i]=other.defense[i];
1886 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1887 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1888
1889 if(new_script_uid)
1890 {
1891 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1892 }
1893 if(clear_parent_script_UID)
1894 {
1895 parent_script_UID = 0;
1896 }
1897 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1898 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1899
1900 for ( int32_t q = 0; q < 8; q++ )
1901 {
1902 initD[q] = other.initD[q];
1903 weap_initiald[q] = other.weap_initiald[q];
1904 }
1905 for ( int32_t q = 0; q < 2; q++ )
1906 {
1907 initA[q] = other.initA[q];
1908 weap_initiala[q] = other.weap_initiala[q];
1909 }
1910 }
1911
1912 esManhandla::esManhandla(esManhandla const & other, bool new_script_uid, bool clear_parent_script_UID):
1913 //Struct Element Type Purpose
1914 //sprite(other),
1915 enemy(other)
1916 {
1917
1918 //arrays
1919 if(other.scrmem)
1920 {
1921 alloc_scriptmem();
1922 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1923
1924 scrmem->scriptData = other.scrmem->scriptData;
1925 }
1926 else scrmem = NULL;
1927 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1928 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1929
1930 for(int32_t i=0; i<edefLAST255; i++)
1931 defense[i]=other.defense[i];
1932 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1933 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1934
1935 if(new_script_uid)
1936 {
1937 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1938 }
1939 if(clear_parent_script_UID)
1940 {
1941 parent_script_UID = 0;
1942 }
1943 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1944 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1945
1946 for ( int32_t q = 0; q < 8; q++ )
1947 {
1948 initD[q] = other.initD[q];
1949 weap_initiald[q] = other.weap_initiald[q];
1950 }
1951 for ( int32_t q = 0; q < 2; q++ )
1952 {
1953 initA[q] = other.initA[q];
1954 weap_initiala[q] = other.weap_initiala[q];
1955 }
1956 }
1957
1958 eGleeok::eGleeok(eGleeok const & other, bool new_script_uid, bool clear_parent_script_UID):
1959 //Struct Element Type Purpose
1960 //sprite(other),
1961 enemy(other),
1962 flameclk(flameclk),
1963 flamehead(flamehead),
1964 necktile(necktile)
1965
1966 {
1967
1968 //arrays
1969
1970 if(other.scrmem)
1971 {
1972 alloc_scriptmem();
1973 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1974
1975 scrmem->scriptData = other.scrmem->scriptData;
1976 }
1977 else scrmem = NULL;
1978 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1979 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1980
1981 for(int32_t i=0; i<edefLAST255; i++)
1982 defense[i]=other.defense[i];
1983 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1984 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1985
1986 if(new_script_uid)
1987 {
1988 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1989 }
1990 if(clear_parent_script_UID)
1991 {
1992 parent_script_UID = 0;
1993 }
1994 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1995 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1996
1997 for ( int32_t q = 0; q < 8; q++ )
1998 {
1999 initD[q] = other.initD[q];
2000 weap_initiald[q] = other.weap_initiald[q];
2001 }
2002 for ( int32_t q = 0; q < 2; q++ )
2003 {
2004 initA[q] = other.initA[q];
2005 weap_initiala[q] = other.weap_initiala[q];
2006 }
2007 }
2008
2009 esGleeok::esGleeok(esGleeok const & other, bool new_script_uid, bool clear_parent_script_UID):
2010 //Struct Element Type Purpose
2011 //sprite(other),
2012 enemy(other),
2013 headtile(headtile),
2014 flyingheadtile(flyingheadtile),
2015 necktile(necktile),
2016 xoffset(xoffset),
2017 yoffset(yoffset),
2018 nx(nx),
2019 ny(ny),
2020 nxoffset(nxoffset),
2021 nyoffset(nyoffset),
2022 parent(parent)
2023
2024 {
2025
2026 //arrays
2027
2028 if(other.scrmem)
2029 {
2030 alloc_scriptmem();
2031 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2032
2033 scrmem->scriptData = other.scrmem->scriptData;
2034 }
2035 else scrmem = NULL;
2036 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2037 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2038
2039 //for ( int32_t q = 0; q < 255; q++ )
2040 //{
2041 // nx[q] = other.nx[q];
2042 // ny[q] = other.ny[q];
2043 // nxoffset[q] = other.nxoffset[q];
2044 // nyoffset[q] = other.nyoffset[q];
2045 //}
2046
2047 for(int32_t i=0; i<edefLAST255; i++)
2048 defense[i]=other.defense[i];
2049 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2050 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2051
2052 if(new_script_uid)
2053 {
2054 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2055 }
2056 if(clear_parent_script_UID)
2057 {
2058 parent_script_UID = 0;
2059 }
2060 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2061 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2062
2063 for ( int32_t q = 0; q < 8; q++ )
2064 {
2065 initD[q] = other.initD[q];
2066 weap_initiald[q] = other.weap_initiald[q];
2067 }
2068 for ( int32_t q = 0; q < 2; q++ )
2069 {
2070 initA[q] = other.initA[q];
2071 weap_initiala[q] = other.weap_initiala[q];
2072 }
2073 }
2074
2075 ePatra::ePatra(ePatra const & other, bool new_script_uid, bool clear_parent_script_UID):
2076 //Struct Element Type Purpose
2077 //sprite(other),
2078 enemy(other),
2079 flycnt(flycnt),
2080 flycnt2(flycnt2),
2081 loopcnt(loopcnt),
2082 lookat(lookat),
2083 circle_x(circle_x),
2084 circle_y(circle_y),
2085 temp_x(temp_x),
2086 temp_y(temp_y),
2087 adjusted(adjusted)
2088
2089 {
2090
2091 //arrays
2092
2093 if(other.scrmem)
2094 {
2095 alloc_scriptmem();
2096 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2097
2098 scrmem->scriptData = other.scrmem->scriptData;
2099 }
2100 else scrmem = NULL;
2101 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2102 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2103
2104 for(int32_t i=0; i<edefLAST255; i++)
2105 defense[i]=other.defense[i];
2106 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2107 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2108
2109 if(new_script_uid)
2110 {
2111 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2112 }
2113 if(clear_parent_script_UID)
2114 {
2115 parent_script_UID = 0;
2116 }
2117 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2118 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2119
2120 for ( int32_t q = 0; q < 8; q++ )
2121 {
2122 initD[q] = other.initD[q];
2123 weap_initiald[q] = other.weap_initiald[q];
2124 }
2125 for ( int32_t q = 0; q < 2; q++ )
2126 {
2127 initA[q] = other.initA[q];
2128 weap_initiala[q] = other.weap_initiala[q];
2129 }
2130 }
2131
2132 ePatraBS::ePatraBS(ePatraBS const & other, bool new_script_uid, bool clear_parent_script_UID):
2133 //Struct Element Type Purpose
2134 //sprite(other),
2135 enemy(other),
2136 flycnt(flycnt),
2137 flycnt2(flycnt2),
2138 loopcnt(loopcnt),
2139 lookat(lookat),
2140 adjusted(adjusted)
2141
2142 {
2143
2144 //arrays
2145
2146 if(other.scrmem)
2147 {
2148 alloc_scriptmem();
2149 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2150
2151 scrmem->scriptData = other.scrmem->scriptData;
2152 }
2153 else scrmem = NULL;
2154 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2155 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2156
2157 for(int32_t i=0; i<edefLAST255; i++)
2158 defense[i]=other.defense[i];
2159 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2160 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2161
2162 if(new_script_uid)
2163 {
2164 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2165 }
2166 if(clear_parent_script_UID)
2167 {
2168 parent_script_UID = 0;
2169 }
2170 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2171 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2172
2173 for ( int32_t q = 0; q < 8; q++ )
2174 {
2175 initD[q] = other.initD[q];
2176 weap_initiald[q] = other.weap_initiald[q];
2177 }
2178 for ( int32_t q = 0; q < 2; q++ )
2179 {
2180 initA[q] = other.initA[q];
2181 weap_initiala[q] = other.weap_initiala[q];
2182 }
2183 }
2184
2185 esPatra::esPatra(esPatra const & other, bool new_script_uid, bool clear_parent_script_UID):
2186 //Struct Element Type Purpose
2187 //sprite(other),
2188 enemy(other)
2189
2190 {
2191
2192 //arrays
2193
2194 if(other.scrmem)
2195 {
2196 alloc_scriptmem();
2197 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2198
2199 scrmem->scriptData = other.scrmem->scriptData;
2200 }
2201 else scrmem = NULL;
2202 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2203 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2204
2205 for ( int32_t q = 0; q < 255; q++ )
2206 {
2207 nx[q] = other.nx[q];
2208 ny[q] = other.ny[q];
2209 nxoffset[q] = other.nxoffset[q];
2210 nyoffset[q] = other.nyoffset[q];
2211 }
2212
2213 for(int32_t i=0; i<edefLAST255; i++)
2214 defense[i]=other.defense[i];
2215 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2216 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2217
2218 if(new_script_uid)
2219 {
2220 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2221 }
2222 if(clear_parent_script_UID)
2223 {
2224 parent_script_UID = 0;
2225 }
2226 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2227 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2228
2229 for ( int32_t q = 0; q < 8; q++ )
2230 {
2231 initD[q] = other.initD[q];
2232 weap_initiald[q] = other.weap_initiald[q];
2233 }
2234 for ( int32_t q = 0; q < 2; q++ )
2235 {
2236 initA[q] = other.initA[q];
2237 weap_initiala[q] = other.weap_initiala[q];
2238 }
2239 }
2240
2241 esPatraBS::esPatraBS(esPatraBS const & other, bool new_script_uid, bool clear_parent_script_UID):
2242 //Struct Element Type Purpose
2243 //sprite(other),
2244 enemy(other)
2245
2246 {
2247
2248 //arrays
2249
2250 if(other.scrmem)
2251 {
2252 alloc_scriptmem();
2253 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2254
2255 scrmem->scriptData = other.scrmem->scriptData;
2256 }
2257 else scrmem = NULL;
2258 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2259 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2260
2261 for ( int32_t q = 0; q < 255; q++ )
2262 {
2263 nx[q] = other.nx[q];
2264 ny[q] = other.ny[q];
2265 nxoffset[q] = other.nxoffset[q];
2266 nyoffset[q] = other.nyoffset[q];
2267 }
2268
2269 for(int32_t i=0; i<edefLAST255; i++)
2270 defense[i]=other.defense[i];
2271 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2272 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2273
2274 if(new_script_uid)
2275 {
2276 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2277 }
2278 if(clear_parent_script_UID)
2279 {
2280 parent_script_UID = 0;
2281 }
2282 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2283 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2284
2285 for ( int32_t q = 0; q < 8; q++ )
2286 {
2287 initD[q] = other.initD[q];
2288 weap_initiald[q] = other.weap_initiald[q];
2289 }
2290 for ( int32_t q = 0; q < 2; q++ )
2291 {
2292 initA[q] = other.initA[q];
2293 weap_initiala[q] = other.weap_initiala[q];
2294 }
2295 }
2296
2297 */
2298
2299
5/10
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43798 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 43798 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 43798 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 43798 times.
✗ Branch 9 not taken.
131394 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
2300 87596 {
2301
1/2
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
43798 x=X;
2302
1/2
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
43798 y=Y;
2303 43798 id=Id;
2304 43798 clk=Clk;
2305
1/2
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
43798 floor_y=y;
2306 43798 ceiling=false;
2307 43798 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
2308 43798 grumble = movestatus = posframe = timer = ox = oy = 0;
2309
4/8
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43798 times.
✓ Branch 4 taken 43798 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 43798 times.
✗ Branch 7 not taken.
43798 yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
2310 43798 did_armos=true;
2311 43798 script_spawned=false;
2312
2313 43798 d = guysbuf + (id & 0xFFF);
2314 43798 hp = d->hp;
2315 43798 starting_hp = hp;
2316 // cs = d->cset;
2317 //d variables
2318
2319 43798 flags=d->flags;
2320 43798 flags2=d->flags2;
2321 43798 s_tile=d->s_tile; //secondary (additional) tile(s)
2322 43798 family=d->family;
2323 43798 dcset=d->cset;
2324 43798 cs=dcset;
2325
3/4
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28607 times.
✓ Branch 3 taken 15191 times.
43798 anim=get_bit(quest_rules,qr_NEWENEMYTILES)?d->e_anim:d->anim;
2326 43798 dp=d->dp;
2327 43798 wdp=d->wdp;
2328 43798 wpn=d->weapon;
2329 43798 wpnsprite = d-> wpnsprite; //2.6 -Z
2330 43798 rate=d->rate;
2331 43798 hrate=d->hrate;
2332
1/2
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
43798 dstep=d->step;
2333 43798 homing=d->homing;
2334 43798 dmisc1=d->misc1;
2335 43798 dmisc2=d->misc2;
2336 43798 dmisc3=d->misc3;
2337 43798 dmisc4=d->misc4;
2338 43798 dmisc5=d->misc5;
2339 43798 dmisc6=d->misc6;
2340 43798 dmisc7=d->misc7;
2341 43798 dmisc8=d->misc8;
2342 43798 dmisc9=d->misc9;
2343 43798 dmisc10=d->misc10;
2344 43798 dmisc11=d->misc11;
2345 43798 dmisc12=d->misc12;
2346 43798 dmisc13=d->misc13;
2347 43798 dmisc14=d->misc14;
2348 43798 dmisc15=d->misc15;
2349 43798 dmisc16=d->misc16;
2350 43798 dmisc17=d->misc17;
2351 43798 dmisc18=d->misc18;
2352 43798 dmisc19=d->misc19;
2353 43798 dmisc20=d->misc20;
2354 43798 dmisc21=d->misc21;
2355 43798 dmisc22=d->misc22;
2356 43798 dmisc23=d->misc23;
2357 43798 dmisc24=d->misc24;
2358 43798 dmisc25=d->misc25;
2359 43798 dmisc26=d->misc26;
2360 43798 dmisc27=d->misc27;
2361 43798 dmisc28=d->misc28;
2362 43798 dmisc29=d->misc29;
2363 43798 dmisc30=d->misc30;
2364 43798 dmisc31=d->misc31;
2365 43798 dmisc32=d->misc32;
2366
3/4
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43363 times.
✓ Branch 3 taken 435 times.
43798 if (get_bit(quest_rules, qr_BROKEN_ATTRIBUTE_31_32))
2367 {
2368 43363 dmisc31 = dmisc32;
2369 43363 dmisc32 = 0;
2370 43363 }
2371 43798 spr_shadow=d->spr_shadow;
2372 43798 spr_death=d->spr_death;
2373 43798 spr_spawn=d->spr_spawn;
2374
2375
2/2
✓ Branch 0 taken 1795718 times.
✓ Branch 1 taken 43798 times.
1839516 for(int32_t i=0; i<edefLAST255; i++)
2376 1795718 defense[i]=d->defense[i];
2377
2378 43798 bgsfx=d->bgsfx;
2379 43798 hitsfx=d->hitsfx;
2380 43798 deadsfx=d->deadsfx;
2381 43798 bosspal=d->bosspal;
2382 43798 parent_script_UID = 0;
2383
2384 43798 frozentile = d->frozentile;
2385
2386 43798 frozencset = d->frozencset;
2387 43798 frozenclock = 0;
2388
2/2
✓ Branch 0 taken 437980 times.
✓ Branch 1 taken 43798 times.
481778 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
2389
2390
2/2
✓ Branch 0 taken 43798 times.
✓ Branch 1 taken 700768 times.
744566 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
2391 //firesfx = 0; //t.b.a -Z
2392 43798 isCore = true; //t.b.a
2393 43798 parentCore = 0; //t.b.a
2394
1/2
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
43798 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2395
2396 43798 firesfx = d->firesfx;
2397
2/2
✓ Branch 0 taken 1401536 times.
✓ Branch 1 taken 43798 times.
1445334 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
2398
2/2
✓ Branch 0 taken 1401536 times.
✓ Branch 1 taken 43798 times.
1445334 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
2399
2400
1/2
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
43798 script = (d->script >= 0) ? d->script : 0; //Dont assign invalid data.
2401 43798 waitdraw = 0;
2402
1/2
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
43798 weaponscript = (d->weaponscript >= 0) ? d->weaponscript : 0; //Dont assign invalid data.
2403
2404
2/2
✓ Branch 0 taken 350384 times.
✓ Branch 1 taken 43798 times.
394182 for ( int32_t q = 0; q < 8; q++ )
2405 {
2406 350384 initD[q] = d->initD[q];
2407 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
2408 350384 weap_initiald[q] = d->weap_initiald[q];
2409 //al_trace("Guys.cpp: Assigning guy.initD[%d]: %d\n",q, d->initD.initD[q]);
2410 //al_trace("Guys.cpp: Assigning guy.initD[%d] from d->initD[%d]: %d\n",q,q, d->initD[q]);
2411 //al_trace("Guys.cpp: guy.initD[%d] is: %d\n",q, initD[q]);
2412 350384 }
2413
2/2
✓ Branch 0 taken 87596 times.
✓ Branch 1 taken 43798 times.
131394 for ( int32_t q = 0; q < 2; q++ )
2414 {
2415 87596 initA[q] = d->initA[q];
2416 87596 weap_initiala[q] = d->weap_initiala[q];
2417 87596 }
2418
2419 43798 stickclk = 0;
2420 43798 submerged = false;
2421 43798 ffcactivated = 0;
2422 43798 hitdir = -1;
2423 43798 dialogue_str = 0; //set by spawn flags.
2424 43798 editorflags = d->editorflags; //set by Enemy Editor
2425 //Set the drawing flag for this sprite.
2426
1/2
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
43798 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
2427
2428
2429
2/2
✓ Branch 0 taken 7409 times.
✓ Branch 1 taken 36389 times.
43798 if(bosspal>-1)
2430 {
2431
1/2
✓ Branch 0 taken 7409 times.
✗ Branch 1 not taken.
7409 loadpalset(csBOSS,pSprite(bosspal));
2432 7409 }
2433
2434
2/2
✓ Branch 0 taken 21110 times.
✓ Branch 1 taken 22688 times.
43798 if(bgsfx>-1)
2435 {
2436
1/2
✓ Branch 0 taken 21110 times.
✗ Branch 1 not taken.
21110 cont_sfx(bgsfx);
2437 21110 }
2438
2439
3/4
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28607 times.
✓ Branch 3 taken 15191 times.
43798 if(get_bit(quest_rules,qr_NEWENEMYTILES))
2440 {
2441 28607 o_tile=d->e_tile;
2442 28607 frate = d->e_frate;
2443 28607 }
2444 else
2445 {
2446 15191 o_tile=d->tile;
2447 15191 frate = d->frate;
2448 }
2449
2450 43798 tile=0; //init to 0 here, but set it later.
2451
2452 43798 scripttile = -1;
2453 43798 scriptflip = -1;
2454 43798 do_animation = 1;
2455 43798 immortal = false;
2456 43798 noSlide = false;
2457 43798 deathexstate = -1;
2458
2459 43798 hashero=false;
2460
2461 // If they forgot the invisibility flag, here's another failsafe:
2462
4/4
✓ Branch 0 taken 2573 times.
✓ Branch 1 taken 41225 times.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 2479 times.
43798 if(o_tile==0 && family!=eeSPINTILE)
2463 2479 flags |= guy_invisible;
2464
2465 // step = d->step/100.0;
2466 // To preserve the odd step values for Keese & Gleeok heads. -L
2467
5/8
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43798 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5299 times.
✓ Branch 5 taken 38499 times.
✓ Branch 6 taken 5299 times.
✗ Branch 7 not taken.
43798 if(dstep==62.0) dstep+=0.5;
2468
5/8
✓ Branch 0 taken 38499 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38499 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✓ Branch 5 taken 38169 times.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
38499 else if(dstep==89) dstep-=1/9;
2469
2470
5/10
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43798 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 43798 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 43798 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 43798 times.
✗ Branch 9 not taken.
43798 step = zslongToFix(dstep*100);
2471
2472
2473 43798 item_set = d->item_set;
2474 43798 grumble = d->grumble;
2475
2476
2/2
✓ Branch 0 taken 33514 times.
✓ Branch 1 taken 10284 times.
43798 if(frate == 0)
2477 10284 frate = 256;
2478
2479 43798 leader = itemguy = dying = scored = false;
2480 43798 canfreeze = count_enemy = true;
2481 43798 mainguy = !(flags & guy_doesntcount);
2482
1/2
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
43798 dir = zc_oldrand()&3;
2483
2484 //2.6 Enemy Editor Hit and TIle Sizes
2485
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 43798 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
43798 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
2486 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
2487 // al_trace("Enemy txsz:%i\n", txsz);
2488
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 43798 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
43798 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
2489
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43798 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43798 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
2490
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43798 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43798 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
2491
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43798 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43798 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
2492
1/2
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
43798 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
2493
1/2
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
43798 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
2494 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
2495
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43798 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43798 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
2496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43798 times.
43798 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
2497 {
2498 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
2499 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
2500 }
2501
2502
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43798 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43798 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
2503
2504 43798 SIZEflags = d->SIZEflags;
2505
2506
8/10
✓ Branch 0 taken 43710 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 43710 times.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 87 times.
43798 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
2507 1 wpn = 0;
2508
2509 //tile should never be 0 after init --Z (failsafe)
2510
4/6
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43798 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42798 times.
✓ Branch 5 taken 1000 times.
43798 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
2511
2512 //Moveflags; for gravity and pit interaction
2513 43798 moveflags = d->moveflags;
2514
3/4
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37737 times.
✓ Branch 3 taken 6061 times.
43798 if(!can_pitfall(false))
2515 {
2516 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
2517 6061 moveflags &= ~FLAG_CAN_PITFALL;
2518 6061 moveflags &= ~FLAG_CAN_WATERDROWN;
2519 6061 }
2520
2521
1/2
✓ Branch 0 taken 43798 times.
✗ Branch 1 not taken.
43798 shieldCanBlock = get_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG)?true:false;
2522 43798 }
2523
2524 //base clone constructor
2525
2526 enemy::enemy(enemy const & other, bool new_script_uid, bool clear_parent_script_UID):
2527 //Struct Element Type Purpose
2528 sprite(other),
2529 //x(other.x), //int32_t
2530 //y(other.y), //int32_t
2531 //id(other.id), //int32_t
2532 //clk(other.clk), //int32_t
2533 floor_y(other.floor_y), //int32_t
2534 fading(other.fading), //int32_t
2535 //misc(other.misc), //int32_t
2536 clk2(other.clk2), //int32_t
2537 clk3(other.clk3), //int32_t
2538 stunclk(other.stunclk), //int32_t
2539 hclk(other.hclk), //int32_t
2540 sclk(other.sclk), //int32_t
2541 superman(other.superman), //int32_t
2542 //grumble(other.grumble), //int32_t
2543 movestatus(other.movestatus), //int32_t
2544 posframe(other.posframe), //int32_t
2545 timer(other.timer), //int32_t
2546 ox(other.ox), //int32_t
2547 oy(other.oy), //int32_t
2548 //yofs(other.yofs), //int32_t
2549 did_armos(other.did_armos), //int32_t
2550 script_spawned(other.script_spawned), //int32_t
2551 d(other.d), //int32_t
2552 hp(other.hp), //int32_t
2553 starting_hp(other.starting_hp), //int32_t
2554 //flags(other.flags), //int32_t
2555
2556 flags2(other.flags2), //int32_t
2557 s_tile(other.s_tile), //int32_t
2558 family(other.family), //int32_t
2559 dcset(other.dcset), //int32_t
2560 //cs(other.cs), //int32_t
2561 anim(other.anim), //int32_t
2562 dp(other.dp), //int32_t
2563 wdp(other.wdp), //int32_t
2564 wpnsprite(other.wpnsprite), //int32_t
2565 rate(other.rate), //int32_t
2566 hrate(other.hrate), //int32_t
2567 dstep(other.dstep), //int32_t
2568
2569 homing(other.homing), //int32_t
2570 dmisc1(other.dmisc1), //int32_t
2571 dmisc2(other.dmisc2), //int32_t
2572 dmisc3(other.dmisc3), //int32_t
2573 dmisc4(other.dmisc4), //int32_t
2574 dmisc5(other.dmisc5), //int32_t
2575 dmisc6(other.dmisc6), //int32_t
2576 dmisc7(other.dmisc7), //int32_t
2577 dmisc8(other.dmisc8), //int32_t
2578 dmisc9(other.dmisc9), //int32_t
2579 dmisc10(other.dmisc10), //int32_t
2580 dmisc11(other.dmisc11), //int32_t
2581 dmisc12(other.dmisc12), //int32_t
2582 dmisc13(other.dmisc13), //int32_t
2583 dmisc14(other.dmisc14), //int32_t
2584 dmisc15(other.dmisc15), //int32_t
2585 dmisc16(other.dmisc16), //int32_t
2586 dmisc17(other.dmisc17), //int32_t
2587 dmisc18(other.dmisc18), //int32_t
2588 dmisc19(other.dmisc19), //int32_t
2589 dmisc20(other.dmisc20), //int32_t
2590 dmisc21(other.dmisc21), //int32_t
2591 dmisc22(other.dmisc22), //int32_t
2592 dmisc23(other.dmisc23), //int32_t
2593 dmisc24(other.dmisc24), //int32_t
2594 dmisc25(other.dmisc25), //int32_t
2595 dmisc26(other.dmisc26), //int32_t
2596 dmisc27(other.dmisc27), //int32_t
2597 dmisc28(other.dmisc28), //int32_t
2598 dmisc29(other.dmisc29), //int32_t
2599 dmisc30(other.dmisc30), //int32_t
2600 dmisc31(other.dmisc31), //int32_t
2601 dmisc32(other.dmisc32), //int32_t
2602 bgsfx(other.bgsfx), //int32_t
2603 hitsfx(other.hitsfx), //int32_t
2604 deadsfx(other.deadsfx), //int32_t
2605 bosspal(other.bosspal), //int32_t
2606 parent_script_UID(other.parent_script_UID), //int32_t
2607 frozentile(other.frozentile), //int32_t
2608 frozencset(other.frozencset), //int32_t
2609 frozenclock(other.frozenclock), //int32_t
2610 isCore(other.isCore), //int32_t
2611 parentCore(other.parentCore), //int32_t
2612 script_UID(other.script_UID), //int32_t
2613 firesfx(other.firesfx), //int32_t
2614 //script(other.script), //int32_t
2615 //waitdraw(other.waitdraw), //int32_t
2616 weaponscript(other.weaponscript), //int32_t
2617 stickclk(other.stickclk), //int32_t
2618 hitdir(other.hitdir), //int32_t
2619 submerged(other.submerged), //int32_t
2620 ffcactivated(other.ffcactivated), //word
2621
2622 dialogue_str(other.dialogue_str), //int32_t
2623 editorflags(other.editorflags), //int32_t
2624 //drawflags(other.drawflags), //int32_t
2625 o_tile(other.o_tile), //int32_t
2626 frate(other.frate), //int32_t
2627 //tile(other.tile), //int32_t
2628 //scripttile(other.scripttile), //int32_t
2629 //scriptflip(other.scriptflip), //int32_t
2630 //do_animation(other.do_animation), //int32_t
2631 immortal(other.immortal), //bool
2632 noSlide(other.noSlide), //bool
2633 deathexstate(other.deathexstate), //int32_t
2634 flags(other.flags), //int32_t
2635 step(other.step), //int32_t
2636
2637 item_set(other.item_set), //int32_t
2638 grumble(other.grumble), //int32_t
2639 leader(other.leader), //int32_t
2640 itemguy(other.itemguy), //int32_t
2641 dying(other.dying), //int32_t
2642 scored(other.scored), //int32_t
2643 //canfreeze(other.canfreeze), //int32_t
2644 count_enemy(other.count_enemy), //int32_t
2645 mainguy(other.mainguy), //int32_t
2646 //dir(other.dir), //int32_t
2647
2648 //txsz(other.txsz), //int32_t
2649 //tysz(other.tysz), //int32_t
2650 //hxsz(other.hxsz), //int32_t
2651 //hysz(other.hysz), //int32_t
2652 //hzsz(other.hzsz), //int32_t
2653 //hxofs(other.hxofs), //int32_t
2654 //hxofs(other.hxofs), //int32_t
2655 //xofs(other.xofs), //int32_t
2656 //yofs(other.yofs), //int32_t
2657 //hzofs(other.hzofs), //int32_t
2658 //zofs(other.zofs), //int32_t
2659
2660 wpn(other.wpn), //int32_t
2661 SIZEflags(other.SIZEflags), //int32_t
2662 hashero(other.hashero)
2663
2664 {
2665
2666 //arrays
2667
2668 if(other.scrmem)
2669 {
2670 alloc_scriptmem();
2671 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2672
2673 scrmem->scriptData = other.scrmem->scriptData;
2674 }
2675 else scrmem = NULL;
2676 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2677 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2678
2679 for(int32_t i=0; i<edefLAST255; i++)
2680 defense[i]=other.defense[i];
2681 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2682 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2683
2684 if(new_script_uid)
2685 {
2686 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2687 }
2688 if(clear_parent_script_UID)
2689 {
2690 parent_script_UID = 0;
2691 }
2692 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2693 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2694
2695 for ( int32_t q = 0; q < 8; q++ )
2696 {
2697 initD[q] = other.initD[q];
2698 weap_initiald[q] = other.weap_initiald[q];
2699 }
2700 for ( int32_t q = 0; q < 2; q++ )
2701 {
2702 initA[q] = other.initA[q];
2703 weap_initiala[q] = other.weap_initiala[q];
2704 }
2705 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
2706 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
2707 // al_trace("Enemy txsz:%i\n", txsz);
2708 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
2709 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
2710 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
2711 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
2712 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
2713 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
2714 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
2715 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
2716 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
2717 {
2718 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
2719 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
2720 }
2721
2722 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
2723
2724
2725
2726
2727 }
2728
2729
2730 489 int32_t enemy::getScriptUID() { return script_UID; }
2731 void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; }
2732 43778 enemy::~enemy()
2733 43778 {
2734
2/4
✓ Branch 0 taken 43778 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43778 times.
✗ Branch 3 not taken.
43778 FFCore.deallocateAllArrays(SCRIPT_NPC, getUID());
2735
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 43775 times.
43778 if(hashero)
2736 {
2737
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 Hero.setEaten(0);
2738 3 hashero=false;
2739 3 }
2740 43778 }
2741
2742
2743 bool enemy::is_move_paused()
2744 {
2745 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
2746 }
2747
2748 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
2749 {
2750 int32_t yg = (special==spw_floater)?8:0;
2751 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
2752 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
2753 if(input_x == -1000)
2754 input_x = dx;
2755 if(input_y == -1000)
2756 input_y = dy;
2757
2758 if(!(moveflags & FLAG_IGNORE_SCREENEDGE)
2759 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
2760 || ((input_x+hxsz-1) >= (240+nb)) || ((input_y+hysz-1) >= (160+nb))))
2761 return true;
2762
2763 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
2764 {
2765 if(ispitfall(dx,dy))
2766 return true;
2767 }
2768
2769 bool flying = false;
2770 bool cansolid = false;
2771 if(moveflags & FLAG_IGNORE_SOLIDITY)
2772 cansolid = true;
2773 switch(special)
2774 {
2775 case spw_clipbottomright:
2776 if(dy>=128 || dx>=208) return true;
2777 break;
2778 case spw_clipright:
2779 break; //if(input_x>=208) return true; break;
2780
2781 case spw_wizzrobe: // fall through
2782 case spw_floater: // Special case for fliers and wizzrobes - hack!
2783 {
2784 if(isdungeon() && !(moveflags & FLAG_IGNORE_SCREENEDGE))
2785 {
2786 if(dy < 32-yg || dy >= 144) return true;
2787 if(dx < 32 || dx >= 224) return true;
2788 }
2789 if(!(moveflags & FLAG_IGNORE_BLOCKFLAGS) && flyerblocked(dx, dy, special, kb))
2790 return true;
2791 cansolid = true;
2792 flying = true;
2793 }
2794 }
2795
2796 dx &= ~7;
2797 dy &= ~7;
2798
2799 if(!flying && !(moveflags & FLAG_IGNORE_BLOCKFLAGS) && groundblocked(dx,dy,kb)) return true;
2800
2801 if (dx < 0 || dx > 255 || dy < 0 || dy > 175)
2802 return !(moveflags & FLAG_IGNORE_SCREENEDGE);
2803 //_walkflag code
2804 mapscr *s1, *s2;
2805 s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL;
2806 s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL;
2807
2808 int32_t cpos=(dx>>4)+(dy&0xF0);
2809 int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos];
2810 newcombo const& c = combobuf[ci];
2811 newcombo const& c1 = combobuf[ci1];
2812 newcombo const& c2 = combobuf[ci2];
2813
2814 int32_t b=1;
2815 if(dx&8) b<<=2;
2816 if(dy&8) b<<=1;
2817
2818 #define iwtr(cmb, x, y, shallow) \
2819 (shallow \
2820 ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \
2821 && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \
2822 : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false))
2823 bool wtr = iwtr(ci, dx, dy, false);
2824 bool shwtr = iwtr(ci, dx, dy, true);
2825 bool pit = ispitfall(dx,dy);
2826
2827 bool canwtr = (moveflags & FLAG_CAN_WATERWALK) || ((moveflags & FLAG_CAN_WATERDROWN) && kb);
2828 bool canpit = (moveflags & FLAG_CAN_PITWALK) || ((moveflags & FLAG_CAN_PITFALL) && kb);
2829 bool needwtr = (moveflags & FLAG_ONLY_WATERWALK);
2830 bool needshwtr = (moveflags & FLAG_ONLY_SHALLOW_WATERWALK);
2831 bool needpit = (moveflags & FLAG_ONLY_PITWALK);
2832
2833 if(!cansolid)
2834 {
2835 int32_t cwalkflag = c.walk & 0xF;
2836 if (c.type == cBRIDGE && get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
2837 if (s1)
2838 {
2839 if (c1.type == cBRIDGE)
2840 {
2841 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
2842 {
2843 int efflag = (c1.walk & 0xF0)>>4;
2844 int newsolid = (c1.walk & 0xF);
2845 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
2846 }
2847 else cwalkflag &= c1.walk;
2848 }
2849 else cwalkflag |= c1.walk & 0xF;
2850 }
2851 if (s2)
2852 {
2853 if (c2.type == cBRIDGE)
2854 {
2855 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
2856 {
2857 int efflag = (c2.walk & 0xF0)>>4;
2858 int newsolid = (c2.walk & 0xF);
2859 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
2860 }
2861 else cwalkflag &= c2.walk;
2862 }
2863 else cwalkflag |= c2.walk & 0xF;
2864 }
2865 if(cwalkflag & b)
2866 return true;
2867 }
2868 if(needwtr || needshwtr || needpit)
2869 {
2870 bool ret = true;
2871 if (needwtr && wtr) ret = false;
2872 else if (needshwtr && shwtr) ret = false;
2873 else if (needpit && pit) ret = false;
2874 return ret;
2875 }
2876 else if(wtr && !canwtr)
2877 return true;
2878 else if(pit && !canpit)
2879 return true;
2880
2881 return false;
2882 }
2883
2884 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
2885 {
2886 if(!(dx || dy)) return true;
2887 zfix bx = x+hxofs, by = y+hyofs; //left/top
2888 zfix rx = bx+hxsz-1, ry = by+hysz-1; //right/bottom
2889 if(!ign_sv && dy < 0) //check gravity
2890 {
2891 if((moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
2892 return false;
2893 }
2894
2895 bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater));
2896
2897 if(dx && !dy)
2898 {
2899 if(dx < 0)
2900 {
2901 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
2902 int mx = (bx+dx).getFloor();
2903 for(zfix ty = 0; by+ty < ry; ty += 8)
2904 {
2905 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
2906 return false;
2907 }
2908 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
2909 return false;
2910 if(nosolid && collide_object(bx+dx,by,-dx,hysz,this))
2911 return false;
2912 }
2913 else
2914 {
2915 int mx = (rx+dx).getCeil();
2916 int lx = mx-hxsz+1;
2917 for(zfix ty = 0; by+ty < ry; ty += 8)
2918 {
2919 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
2920 return false;
2921 }
2922 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
2923 return false;
2924 if(nosolid && collide_object(bx+hxsz,by,dx,hysz,this))
2925 return false;
2926 }
2927 }
2928 else if(dy && !dx)
2929 {
2930 if(dy < 0)
2931 {
2932 special = (special==spw_clipbottomright)?spw_none:special;
2933 int my = (by+dy).getFloor();
2934 for(zfix tx = 0; bx+tx < rx; tx += 8)
2935 {
2936 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
2937 return false;
2938 }
2939 if(scr_walkflag(rx, my, special, up, bx, my, kb))
2940 return false;
2941 if(nosolid && collide_object(bx,by+dy,hxsz,-dy,this))
2942 return false;
2943 }
2944 else
2945 {
2946 int my = (ry+dy).getCeil();
2947 int ly = my-hysz+1;
2948 for(zfix tx = 0; bx+tx < rx; tx += 8)
2949 {
2950 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
2951 return false;
2952 }
2953 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
2954 return false;
2955 if(nosolid && collide_object(bx,by+hysz,hxsz,dy,this))
2956 return false;
2957 }
2958 }
2959 else //! Untested, and currently unused.
2960 {
2961 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
2962 }
2963 return true;
2964 }
2965
2966 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
2967 {
2968 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
2969 zfix rx = bx+hxsz-1, ry = by+hysz-1; //right/bottom
2970
2971 bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater));
2972
2973 if(nosolid && collide_object(bx,by,hxsz,hysz,this))
2974 return false;
2975 for(zfix ty = 0; by+ty < ry; ty += 8)
2976 {
2977 for(zfix tx = 0; bx+tx < rx; tx += 8)
2978 {
2979 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
2980 return false;
2981 }
2982 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
2983 return false;
2984 }
2985 for(zfix tx = 0; bx+tx < rx; tx += 8)
2986 {
2987 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
2988 return false;
2989 }
2990 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
2991 return false;
2992 return true;
2993 }
2994
2995 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
2996 {
2997 auto oxsz = hxsz, oysz = hysz;
2998 if(nwid > -1) hxsz = nwid;
2999 if(nhei > -1) hysz = nhei;
3000 bool ret = scr_canplace(dx,dy,special,kb);
3001 hxsz = oxsz; hysz = oysz;
3002 return ret;
3003 }
3004
3005 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
3006 {
3007 bool ret = true;
3008 if(!ign_sv && dy < 0 && (moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
3009 dy = 0;
3010 const int scl = 2;
3011 while(abs(dx) > scl || abs(dy) > scl)
3012 {
3013 if(abs(dx) > abs(dy))
3014 {
3015 int32_t tdx = dx.sign() * scl;
3016 if(movexy(tdx, 0, special, kb, ign_sv))
3017 dx -= tdx;
3018 else
3019 {
3020 dx = tdx;
3021 ret = false;
3022 }
3023 }
3024 else
3025 {
3026 int32_t tdy = dy.sign() * scl;
3027 if(movexy(0, tdy, special, kb, ign_sv))
3028 dy -= tdy;
3029 else
3030 {
3031 dy = tdy;
3032 ret = false;
3033 }
3034 }
3035 }
3036
3037 if(dx)
3038 {
3039 if(scr_canmove(dx, 0, special, kb, ign_sv))
3040 x += dx;
3041 else
3042 {
3043 ret = false;
3044 int xsign = dx.sign();
3045 while(scr_canmove(xsign, 0, special, kb, ign_sv))
3046 {
3047 x += xsign;
3048 dx -= xsign;
3049 }
3050 zfix dxsign = dx.decsign();
3051 while(scr_canmove(dxsign, 0, special, kb, ign_sv))
3052 {
3053 x += dxsign;
3054 dx -= dxsign;
3055 }
3056 }
3057 }
3058 if(dy)
3059 {
3060 if(scr_canmove(0, dy, special, kb, ign_sv))
3061 y += dy;
3062 else
3063 {
3064 ret = false;
3065 int ysign = dy.sign();
3066 while(scr_canmove(0, ysign, special, kb, ign_sv))
3067 {
3068 y += ysign;
3069 dy -= ysign;
3070 }
3071 zfix dysign = dy.decsign();
3072 while(scr_canmove(0, dysign, special, kb, ign_sv))
3073 {
3074 y += dysign;
3075 dy -= dysign;
3076 }
3077 }
3078 }
3079 return ret;
3080 }
3081
3082 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb)
3083 {
3084 zfix diagrate = zslongToFix(7071);
3085 switch(NORMAL_DIR(dir))
3086 {
3087 case up:
3088 return movexy(0, -px, special, kb);
3089 case down:
3090 return movexy(0, px, special, kb);
3091 case left:
3092 return movexy(-px, 0, special, kb);
3093 case right:
3094 return movexy(px, 0, special, kb);
3095 case r_up:
3096 return movexy(px*diagrate, -px*diagrate, special, kb);
3097 case r_down:
3098 return movexy(px*diagrate, px*diagrate, special, kb);
3099 case l_up:
3100 return movexy(-px*diagrate, -px*diagrate, special, kb);
3101 case l_down:
3102 return movexy(-px*diagrate, px*diagrate, special, kb);
3103 }
3104 return false;
3105 }
3106
3107 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
3108 {
3109 double v = degrees.getFloat() * PI / 180.0;
3110 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
3111 return movexy(dx, dy, special, kb);
3112 }
3113
3114 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
3115 {
3116 zfix tx = x, ty = y;
3117 bool ret = movexy(dx, dy, special, kb);
3118 x = tx;
3119 y = ty;
3120 return ret;
3121 }
3122 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
3123 {
3124 zfix tx = x, ty = y;
3125 bool ret = moveDir(dir, px, special, kb);
3126 x = tx;
3127 y = ty;
3128 return ret;
3129 }
3130 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
3131 {
3132 zfix tx = x, ty = y;
3133 bool ret = moveAtAngle(degrees, px, special, kb);
3134 x = tx;
3135 y = ty;
3136 return ret;
3137 }
3138
3139 // Handle pitfalls
3140 17937851 bool enemy::do_falling(int32_t index)
3141 {
3142
2/2
✓ Branch 0 taken 17937709 times.
✓ Branch 1 taken 142 times.
17937851 if(fallclk > 0)
3143 {
3144
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
142 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
3145
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 4 times.
142 if(!--fallclk)
3146 {
3147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(immortal) //Keep alive forever
3148 ++fallclk; //force another frame of falling.... forever.
3149
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(dying) //Give 1 frame for script revival
3150 {
3151
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags&guy_neverret)
3152 never_return(index);
3153
3154
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(leader)
3155 kill_em_all();
3156
3157 //leave_item(); //Don't drop items in pits!
3158 2 stop_bgsfx(index);
3159 2 return true;
3160 }
3161 else
3162 {
3163 2 try_death(true); //Force death
3164 2 ++fallclk; //force another frame of falling
3165 }
3166 2 }
3167
3168 140 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
3169 140 cs = spr.csets & 0xF;
3170
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t fr = spr.frames ? spr.frames : 1;
3171
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t spd = spr.speed ? spr.speed : 1;
3172 140 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
3173
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 82 times.
140 tile = spr.tile + zc_min(animclk / spd, fr-1);
3174 140 }
3175 17937849 return false;
3176 17937851 }
3177
3178 // Handle drowning in water
3179 17937709 bool enemy::do_drowning(int32_t index)
3180 {
3181
1/2
✓ Branch 0 taken 17937709 times.
✗ Branch 1 not taken.
17937709 if(drownclk > 0)
3182 {
3183 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
3184 //!TODO: Drown SFX
3185 if(!--drownclk)
3186 {
3187 if(immortal) //Keep alive forever
3188 ++drownclk; //force another frame of falling.... forever.
3189 else if(dying) //Give 1 frame for script revival
3190 {
3191 if(flags&guy_neverret)
3192 never_return(index);
3193
3194 if(leader)
3195 kill_em_all();
3196
3197 //leave_item(); //Don't drop items in pits!
3198 stop_bgsfx(index);
3199 return true;
3200 }
3201 else
3202 {
3203 try_death(true); //Force death
3204 ++drownclk; //force another frame of falling
3205 }
3206 }
3207
3208 if (drownCombo && combobuf[drownCombo].usrflags&cflag1)
3209 {
3210 wpndata &spr = wpnsbuf[QMisc.sprites[sprLAVADROWN]];
3211 cs = spr.csets & 0xF;
3212 int32_t fr = spr.frames ? spr.frames : 1;
3213 int32_t spd = spr.speed ? spr.speed : 1;
3214 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
3215 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
3216 }
3217 else
3218 {
3219 wpndata &spr = wpnsbuf[QMisc.sprites[sprDROWN]];
3220 cs = spr.csets & 0xF;
3221 int32_t fr = spr.frames ? spr.frames : 1;
3222 int32_t spd = spr.speed ? spr.speed : 1;
3223 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
3224 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
3225 }
3226 }
3227 17937709 return false;
3228 17937709 }
3229
3230 // Supplemental animation code that all derived classes should call
3231 // as a return value for animate().
3232 // Handles the death animation and returns true when enemy is finished.
3233 18280038 bool enemy::Dead(int32_t index)
3234 {
3235
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 18278209 times.
18280038 if(immortal)
3236 {
3237 1829 dying = false;
3238 1829 return false;
3239 }
3240
2/2
✓ Branch 0 taken 368766 times.
✓ Branch 1 taken 17909443 times.
18278209 if(dying)
3241 {
3242
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 368765 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
368766 if(deathexstate > -1 && deathexstate < 32)
3243 {
3244 1 setxmapflag(1<<deathexstate);
3245 1 deathexstate = -1;
3246 1 }
3247 368766 --clk2;
3248
3249
4/4
✓ Branch 0 taken 364071 times.
✓ Branch 1 taken 4695 times.
✓ Branch 2 taken 18727 times.
✓ Branch 3 taken 502 times.
368766 if((get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
3250
2/2
✓ Branch 0 taken 19229 times.
✓ Branch 1 taken 344842 times.
364071 && hp>-1000) // not killed by ringleader
3251 18727 death_sfx();
3252
3253
2/2
✓ Branch 0 taken 349314 times.
✓ Branch 1 taken 19452 times.
368766 if(clk2==0)
3254 {
3255
2/2
✓ Branch 0 taken 19068 times.
✓ Branch 1 taken 384 times.
19452 if(flags&guy_neverret)
3256 384 never_return(index);
3257
3258
2/2
✓ Branch 0 taken 19399 times.
✓ Branch 1 taken 53 times.
19452 if(leader)
3259 53 kill_em_all();
3260
3261 19452 leave_item();
3262 19452 }
3263
3264 368766 stop_bgsfx(index);
3265 368766 return (clk2==0);
3266 }
3267
3268 17909443 return false;
3269 18280038 }
3270
3271 // Basic animation code that all derived classes should call.
3272 // The one with an index is the one that is called by
3273 // the guys sprite list; index is the enemy's index in the list.
3274 18693253 bool enemy::animate(int32_t index)
3275 {
3276
2/2
✓ Branch 0 taken 1550463 times.
✓ Branch 1 taken 17142790 times.
18693253 if(sclk <= 0) hitdir = -1;
3277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16956797 times.
18693253 if(switch_hooked)
3278 {
3279 if(get_bit(quest_rules, qr_SWITCHOBJ_RUN_SCRIPT))
3280 {
3281 //Run its script
3282 if (run_script(MODE_NORMAL)==RUNSCRIPT_SELFDELETE)
3283 {
3284 return 0; //Avoid NULLPO if this object deleted itself
3285 }
3286 }
3287 return false;
3288 }
3289
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 16956795 times.
16956797 if(do_falling(index)) return true;
3290
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 16956655 times.
16956795 else if(fallclk)
3291 {
3292 //clks
3293
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 60 times.
140 if(hclk>0)
3294 60 --hclk;
3295
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(stunclk>0)
3296 --stunclk;
3297
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( frozenclock > 0 )
3298 --frozenclock;
3299
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(hashero)
3300 {
3301 Hero.setX(x);
3302 Hero.setY(y);
3303 Hero.fallCombo = fallCombo;
3304 Hero.fallclk = fallclk;
3305 hashero = false; //Let Hero go if falling
3306 }
3307 140 run_script(MODE_NORMAL);
3308 140 return false;
3309 }
3310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16956655 times.
16956655 if(do_drowning(index)) return true;
3311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16956655 times.
16956655 else if(drownclk)
3312 {
3313 //clks
3314 if(hclk>0)
3315 --hclk;
3316 if(stunclk>0)
3317 --stunclk;
3318 if ( frozenclock > 0 )
3319 --frozenclock;
3320 if(hashero)
3321 {
3322 Hero.setX(x);
3323 Hero.setY(y);
3324 Hero.drownclk = drownclk;
3325 hashero = false; //Let Hero go if falling
3326 }
3327 run_script(MODE_NORMAL);
3328 return false;
3329 }
3330 16956655 int32_t nx = real_x(x);
3331 16956655 int32_t ny = real_y(y);
3332
3333
4/4
✓ Branch 0 taken 13197851 times.
✓ Branch 1 taken 3758804 times.
✓ Branch 2 taken 3578870 times.
✓ Branch 3 taken 14830791 times.
16956655 if(ox!=nx || oy!=ny)
3334 {
3335 7337674 posframe=(posframe+1)%(get_bit(quest_rules,qr_NEWENEMYTILES)?4:2);
3336 7337674 }
3337
3338 22168465 ox = nx;
3339 22168465 oy = ny;
3340
3341 // Maybe they fell off the bottom in sideview, or were moved by a script.
3342
3343 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
3344
2/2
✓ Branch 0 taken 4232585 times.
✓ Branch 1 taken 17935880 times.
22168465 if ( immortal )
3345 {
3346 //skip, as it can go out of bounds, from immortality
3347 4232585 }
3348
2/6
✓ Branch 0 taken 17935880 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17935880 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17935880 else if ( (moveflags & FLAG_IGNORE_SCREENEDGE) || (( (get_bit(quest_rules, qr_OUTOFBOUNDSENEMIES)) != (editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
3349 {
3350 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
3351 }
3352
9/10
✓ Branch 0 taken 17539787 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 17935551 times.
✓ Branch 3 taken 329 times.
✓ Branch 4 taken 17935506 times.
✓ Branch 5 taken 45 times.
✓ Branch 6 taken 17935506 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✓ Branch 9 taken 17935470 times.
17935880 else if ( (OUTOFBOUNDS) )
3353 {
3354 410 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
3355 410 }
3356 //fall down
3357
6/6
✓ Branch 0 taken 11346397 times.
✓ Branch 1 taken 10822068 times.
✓ Branch 2 taken 6432350 times.
✓ Branch 3 taken 15736115 times.
✓ Branch 4 taken 292165 times.
✓ Branch 5 taken 6140185 times.
22168465 if((enemycanfall(id) || (moveflags & FLAG_OBEYS_GRAV) )&& fading != fade_flicker && clk>=0)
3358 {
3359
2/2
✓ Branch 0 taken 303574 times.
✓ Branch 1 taken 5836611 times.
6140185 if(isSideViewGravity())
3360 {
3361
1/2
✓ Branch 0 taken 303574 times.
✗ Branch 1 not taken.
303574 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
3362 {
3363
2/2
✓ Branch 0 taken 176339 times.
✓ Branch 1 taken 127235 times.
303574 if(!isOnSideviewPlatform())
3364 {
3365 127235 bool willHitSVPlatform = false;
3366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH)?hxsz:16;
3367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT)?hysz:16;
3368
2/2
✓ Branch 0 taken 127235 times.
✓ Branch 1 taken 127235 times.
254470 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
3369 {
3370
5/8
✓ Branch 0 taken 23361 times.
✓ Branch 1 taken 103874 times.
✓ Branch 2 taken 23361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 127235 times.
✗ Branch 7 not taken.
127235 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
3371 {
3372 willHitSVPlatform = true;
3373 break;
3374 }
3375 127235 }
3376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 if(willHitSVPlatform)
3377 {
3378 y+=fall/100;
3379 //y-=int32_t(y)%16; //Fix to top of SV Ladder
3380 do_fix(y, 16); //Fix to top of SV Ladder
3381 fall = 0;
3382 }
3383 else
3384 {
3385 127235 y+=fall/100;
3386
2/2
✓ Branch 0 taken 17808 times.
✓ Branch 1 taken 109427 times.
127235 if(fall <= (int32_t)zinit.terminalv)
3387 109427 fall += (zinit.gravity2/100);
3388 }
3389 127235 }
3390 else
3391 {
3392
2/2
✓ Branch 0 taken 176072 times.
✓ Branch 1 taken 267 times.
176339 if(fall!=0) // Only fix pos once
3393 {
3394 //y-=(int32_t)y%8; // Fix position
3395 267 do_fix(y, 8); //Fix position
3396 267 }
3397
3398 176339 fall = 0;
3399 }
3400 303574 }
3401 else
3402 {
3403 if(isOnSideviewPlatform())
3404 fall = 0;
3405 else
3406 {
3407 zfix fall_amnt = fall/100;
3408 bool hit = false;
3409 while(fall_amnt >= 1)
3410 {
3411 --fall_amnt;
3412 ++y;
3413 if(isOnSideviewPlatform())
3414 {
3415 y = y.getInt();
3416 fall_amnt = 0;
3417 hit = true;
3418 break;
3419 }
3420 }
3421 if(fall_amnt > 0)
3422 y += fall_amnt;
3423 if(fall_amnt < 0)
3424 {
3425 if(!movexy(0,fall_amnt,spw_none))
3426 hit = true;
3427 }
3428 if(hit)
3429 fall = 0;
3430 else if(fall <= (int32_t)zinit.terminalv)
3431 fall += (zinit.gravity2/100);
3432 }
3433 }
3434 303574 }
3435 else
3436 {
3437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5836611 times.
5836611 if (!(moveflags & FLAG_NO_FAKE_Z))
3438 {
3439
2/2
✓ Branch 0 taken 2944613 times.
✓ Branch 1 taken 2891998 times.
5836611 if(fakefall!=0)
3440 2891998 fakez-=(fakefall/100);
3441
3442
2/2
✓ Branch 0 taken 2891998 times.
✓ Branch 1 taken 2944613 times.
5836611 if(fakez<0)
3443 2891998 fakez = fakefall = 0;
3444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2944613 times.
2944613 else if(fakefall <= (int32_t)zinit.terminalv)
3445 2944613 fakefall += (zinit.gravity2/100);
3446
3447
5/6
✓ Branch 0 taken 5836611 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2944613 times.
✓ Branch 3 taken 2891998 times.
✓ Branch 4 taken 2899012 times.
✓ Branch 5 taken 45601 times.
5836611 if (fakez<=0 && fakefall > 0 && !get_bit(quest_rules, qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
3448 5836611 }
3449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5836611 times.
5836611 if (!(moveflags & FLAG_NO_REAL_Z))
3450 {
3451
2/2
✓ Branch 0 taken 2951979 times.
✓ Branch 1 taken 2884632 times.
5836611 if(fall!=0)
3452 2884632 z-=(fall/100);
3453
3454
2/2
✓ Branch 0 taken 2878808 times.
✓ Branch 1 taken 2957803 times.
5836611 if(z<0)
3455 2878808 z = fall = 0;
3456
2/2
✓ Branch 0 taken 4644 times.
✓ Branch 1 taken 2953159 times.
2957803 else if(fall <= (int32_t)zinit.terminalv)
3457 2953159 fall += (zinit.gravity2/100);
3458
3459
6/6
✓ Branch 0 taken 5830690 times.
✓ Branch 1 taken 5921 times.
✓ Branch 2 taken 2951882 times.
✓ Branch 3 taken 2878808 times.
✓ Branch 4 taken 2906281 times.
✓ Branch 5 taken 45601 times.
5836611 if (z<=0 && fall > 0 && !get_bit(quest_rules, qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
3460 5836611 }
3461
3462 }
3463 6140185 }
3464
4/4
✓ Branch 0 taken 17541616 times.
✓ Branch 1 taken 4626849 times.
✓ Branch 2 taken 8242663 times.
✓ Branch 3 taken 16229331 times.
22168465 if(!isSideViewGravity() && (moveflags & FLAG_CAN_PITFALL))
3465 {
3466
8/10
✓ Branch 0 taken 5417234 times.
✓ Branch 1 taken 10812097 times.
✓ Branch 2 taken 5410249 times.
✓ Branch 3 taken 6985 times.
✓ Branch 4 taken 5410249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5417234 times.
✓ Branch 8 taken 5410249 times.
✓ Branch 9 taken 5410249 times.
16229331 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
3467 {
3468 5410249 fallCombo = check_pits();
3469 5410249 }
3470 27049829 }
3471
3/4
✓ Branch 0 taken 17541616 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 17541616 times.
✗ Branch 3 not taken.
18295147 if(!isSideViewGravity() && (moveflags & FLAG_CAN_WATERDROWN))
3472 {
3473 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
3474 {
3475 drownCombo = check_water();
3476 }
3477 }
3478
3479 17937709 runKnockback(); //scripted knockback handling
3480
3481 // clk is incremented here
3482
2/2
✓ Branch 0 taken 17006608 times.
✓ Branch 1 taken 931101 times.
17937709 if(++clk >= frate)
3483 931101 clk=0;
3484
3485 // hit and death handling
3486
2/2
✓ Branch 0 taken 17320604 times.
✓ Branch 1 taken 617105 times.
17937709 if(hclk>0)
3487 617105 --hclk;
3488
3489
2/2
✓ Branch 0 taken 17579182 times.
✓ Branch 1 taken 358527 times.
17937709 if(stunclk>0)
3490 358527 --stunclk;
3491
1/2
✓ Branch 0 taken 17937709 times.
✗ Branch 1 not taken.
17937709 if ( frozenclock > 0 )
3492 --frozenclock;
3493
3494
5/6
✓ Branch 0 taken 7002 times.
✓ Branch 1 taken 17930707 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 6947 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
17937709 if(ceiling && z <= 0 && fakez <= 0)
3495 55 ceiling = false;
3496
3497 17937709 try_death();
3498
3499 17937709 scored=false;
3500
3501 17937709 ++c_clk;
3502
3503 //Run its script
3504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17937709 times.
17937709 if (run_script(MODE_NORMAL)==RUNSCRIPT_SELFDELETE)
3505 {
3506 return 0; //Avoid NULLPO if this object deleted itself
3507 }
3508
3509 // returns true when enemy is defeated
3510 17937709 return Dead(index);
3511 17937851 }
3512
3513 18318250 bool enemy::setSolid(bool set)
3514 {
3515
1/2
✓ Branch 0 taken 18318250 times.
✗ Branch 1 not taken.
18318250 bool actual = set && !isSubmerged();
3516 18318250 bool ret = solid_object::setSolid(actual);
3517 18318250 solid = set;
3518 18318250 return ret;
3519 }
3520 void enemy::doContactDamage(int32_t hdir)
3521 {
3522 Hero.hithero(guys.find(this), hdir);
3523 }
3524
3525 3278 void enemy::solid_push(solid_object *obj)
3526 {
3527
1/2
✓ Branch 0 taken 3278 times.
✗ Branch 1 not taken.
3278 if(obj == this) return; //can't push self
3528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
3278 if(moveflags&FLAG_NOT_PUSHABLE) return; //not pushable
3529 3278 zfix dx, dy;
3530 3278 int32_t hdir = -1;
3531 3278 solid_push_int(obj,dx,dy,hdir);
3532
3533
2/4
✓ Branch 0 taken 3278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3278 times.
✗ Branch 3 not taken.
3278 if(!dx && !dy) return;
3534
3535 bool t = obj->getTempNonsolid();
3536 obj->setTempNonsolid(true);
3537
3538 int32_t ydir = dy > 0 ? down : up;
3539 int32_t xdir = dx > 0 ? right : left;
3540
3541 auto special = isflier(id) ? spw_floater : spw_none;
3542 if(!movexy(dx,dy,special,true,true))
3543 {
3544 //Crushed?
3545 }
3546
3547 obj->setTempNonsolid(t);
3548 3278 }
3549 3278 bool enemy::is_unpushable() const
3550 {
3551 3278 return isSubmerged();
3552 }
3553 3278 bool enemy::sideview_mode() const
3554 {
3555
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3278 return isSideViewGravity() && (moveflags&FLAG_OBEYS_GRAV) && !(moveflags&FLAG_NOT_PUSHABLE);
3556 }
3557
3558 2447 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
3559 {
3560 2447 int32_t yg = (special==spw_floater)?8:0;
3561 2447 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
3562
3563
8/10
✓ Branch 0 taken 1858 times.
✓ Branch 1 taken 589 times.
✓ Branch 2 taken 533 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1860 times.
✓ Branch 9 taken 2449 times.
2447 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
3564 3718 return true;
3565
3566 2449 bool isInDungeon = isdungeon();
3567
3/4
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 2334 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
2449 if(isInDungeon || special==spw_wizzrobe)
3568 {
3569
7/8
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 1863 times.
✓ Branch 2 taken 466 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 472 times.
✓ Branch 5 taken 1396 times.
✓ Branch 6 taken 472 times.
✗ Branch 7 not taken.
2334 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
3570 938 return true;
3571
3572
7/8
✓ Branch 0 taken 465 times.
✓ Branch 1 taken 931 times.
✓ Branch 2 taken 466 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 466 times.
✓ Branch 5 taken 466 times.
✓ Branch 6 taken 466 times.
✗ Branch 7 not taken.
1396 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
3573
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
932 if(special!=spw_door) // walk in door way
3574 return true;
3575 466 }
3576
3577
3/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 542 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
581 if(!(moveflags & FLAG_CAN_PITWALK) && !(moveflags & FLAG_CAN_PITFALL)) //Don't walk into pits (knockback doesn't call this func)
3578 {
3579
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
78 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
3580
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
3581 return true;
3582 39 }
3583
3584
1/4
✓ Branch 0 taken 581 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
581 switch(special)
3585 {
3586 case spw_clipbottomright:
3587 if(dy>=128 || dx>=208) return true;
3588 break;
3589 case spw_clipright:
3590 break; //if(x>=208) return true; break;
3591
3592 case spw_wizzrobe: // fall through
3593 case spw_floater: // Special case for fliers and wizzrobes - hack!
3594 {
3595
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 466 times.
581 if(isInDungeon)
3596 {
3597
2/4
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 466 times.
466 if(dy < 32-yg || dy >= 144) return true;
3598
2/4
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 466 times.
466 if(dx < 32 || dx >= 224) return true;
3599 466 }
3600 581 return false;
3601 }
3602 }
3603
3604 dx&=(special==spw_halfstep)?(~7):(~15);
3605 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
3606
3607 if(special==spw_water)
3608 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
3609
3610 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3611 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
3612 589 }
3613
3614 745 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
3615 {
3616 745 bool kb = false;
3617 745 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
3618
3619
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 745 times.
✓ Branch 2 taken 637 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 745 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 745 times.
745 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb)
3620 return true;
3621
3622
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 619 times.
745 if(isdungeon())
3623 {
3624
2/4
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 619 times.
619 if((dy<32) || (dy>=144))
3625 return true;
3626
3627
2/4
✓ Branch 0 taken 619 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 619 times.
619 if((dx<32) || (dx>=224))
3628 return true;
3629 619 }
3630
3631
2/4
✓ Branch 0 taken 745 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 745 times.
745 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL))) //Don't walk into pits, unless being knocked back
3632 {
3633
2/4
✓ Branch 0 taken 745 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 745 times.
1490 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
3634
2/4
✓ Branch 0 taken 745 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 745 times.
✗ Branch 3 not taken.
745 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
3635 return true;
3636 745 }
3637
3638
1/2
✓ Branch 0 taken 745 times.
✗ Branch 1 not taken.
745 if(get_bit(quest_rules,qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
3639 {
3640
3/4
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 721 times.
✗ Branch 3 not taken.
1466 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 721 times.
721 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3642 }
3643 else
3644 {
3645 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
3646 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3647 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
3648 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3649 }
3650 745 }
3651
3652 17639324 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
3653 {
3654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17639324 times.
17639324 if(moveflags & FLAG_USE_NEW_MOVEMENT)
3655 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
3656 17639324 int32_t yg = (special==spw_floater)?8:0;
3657 17639324 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
3658
2/2
✓ Branch 0 taken 1709473 times.
✓ Branch 1 taken 15929851 times.
17639324 switch(dir)
3659 {
3660 case l_down:
3661 case r_down:
3662 case down:
3663 case 11: //r_down
3664 case 12: //down
3665 case 13: //l_down
3666 {
3667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1709473 times.
1709473 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
3668 {
3669
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1709473 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1709473 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT && !isflier(id) )
3670 {
3671 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
3672 dy += zc_max(hysz-16,0);
3673 }
3674 1709473 }
3675 1709473 break;
3676 }
3677 }
3678
2/2
✓ Branch 0 taken 1718606 times.
✓ Branch 1 taken 15920718 times.
17639324 switch(dir)
3679 {
3680 case r_up:
3681 case r_down:
3682 case right:
3683 case 9: //r_up
3684 case 10: //right
3685 case 11: //r_down
3686 {
3687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1718606 times.
1718606 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
3688 {
3689
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1718606 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1718606 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH && !isflier(id) )
3690 {
3691 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
3692 dx += zc_max(hxsz-16,0);
3693 }
3694 1718606 }
3695 1718606 break;
3696 }
3697 }
3698 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
3699
3700
10/10
✓ Branch 0 taken 13036076 times.
✓ Branch 1 taken 4603248 times.
✓ Branch 2 taken 1103409 times.
✓ Branch 3 taken 3499839 times.
✓ Branch 4 taken 4594604 times.
✓ Branch 5 taken 8644 times.
✓ Branch 6 taken 4584010 times.
✓ Branch 7 taken 10594 times.
✓ Branch 8 taken 13057165 times.
✓ Branch 9 taken 17641175 times.
17639324 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
3701 26112479 return true;
3702
3703 17641175 bool isInDungeon = isdungeon();
3704
4/4
✓ Branch 0 taken 1082055 times.
✓ Branch 1 taken 16559120 times.
✓ Branch 2 taken 611 times.
✓ Branch 3 taken 1081444 times.
17641175 if(isInDungeon || special==spw_wizzrobe)
3705 {
3706
8/8
✓ Branch 0 taken 3416371 times.
✓ Branch 1 taken 13143360 times.
✓ Branch 2 taken 3293847 times.
✓ Branch 3 taken 122524 times.
✓ Branch 4 taken 3377696 times.
✓ Branch 5 taken 9888188 times.
✓ Branch 6 taken 3377682 times.
✓ Branch 7 taken 14 times.
16559731 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144))
3707 6671529 return true;
3708
3709
8/8
✓ Branch 0 taken 3332554 times.
✓ Branch 1 taken 6555648 times.
✓ Branch 2 taken 3239355 times.
✓ Branch 3 taken 93199 times.
✓ Branch 4 taken 3302491 times.
✓ Branch 5 taken 3346356 times.
✓ Branch 6 taken 3302488 times.
✓ Branch 7 taken 3 times.
9888202 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224))
3710
2/2
✓ Branch 0 taken 63098 times.
✓ Branch 1 taken 35 times.
6541843 if(special!=spw_door) // walk in door way
3711 63098 return true;
3712 3346394 }
3713
3714
6/6
✓ Branch 0 taken 1640220 times.
✓ Branch 1 taken 2787618 times.
✓ Branch 2 taken 423850 times.
✓ Branch 3 taken 1216370 times.
✓ Branch 4 taken 34241 times.
✓ Branch 5 taken 389609 times.
4427838 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
3715 {
3716
3/4
✓ Branch 0 taken 1605972 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1605972 times.
3211951 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
3717
2/4
✓ Branch 0 taken 1605972 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1605972 times.
✗ Branch 3 not taken.
1605972 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
3718 7 return true;
3719 1605972 }
3720
3721
4/4
✓ Branch 0 taken 3564723 times.
✓ Branch 1 taken 859849 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 3214 times.
4427831 switch(special)
3722 {
3723 case spw_clipbottomright:
3724
2/4
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
45 if(dy>=128 || dx>=208) return true;
3725 45 break;
3726 case spw_clipright:
3727 3214 break; //if(input_x>=208) return true; break;
3728
3729 case spw_wizzrobe: // fall through
3730 case spw_floater: // Special case for fliers and wizzrobes - hack!
3731 {
3732
2/2
✓ Branch 0 taken 718985 times.
✓ Branch 1 taken 2845738 times.
3564723 if(isInDungeon)
3733 {
3734
3/4
✓ Branch 0 taken 2845727 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2845727 times.
2845738 if(dy < 32-yg || dy >= 144) return true;
3735
3/4
✓ Branch 0 taken 2844910 times.
✓ Branch 1 taken 817 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2844910 times.
2845727 if(dx < 32 || dx >= 224) return true;
3736 2844910 }
3737 3563895 return false;
3738 }
3739 }
3740
3741 863108 dx&=(special==spw_halfstep)?(~7):(~15);
3742
2/2
✓ Branch 0 taken 189436 times.
✓ Branch 1 taken 673672 times.
863108 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
3743
3744
2/2
✓ Branch 0 taken 107261 times.
✓ Branch 1 taken 755847 times.
863108 if(special==spw_water)
3745
2/2
✓ Branch 0 taken 6275 times.
✓ Branch 1 taken 100986 times.
107261 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
3746
3747
2/2
✓ Branch 0 taken 753718 times.
✓ Branch 1 taken 2129 times.
755847 if(get_bit(quest_rules,qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
3748 {
3749
4/4
✓ Branch 0 taken 570386 times.
✓ Branch 1 taken 183332 times.
✓ Branch 2 taken 565492 times.
✓ Branch 3 taken 4894 times.
1319210 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3750
2/2
✓ Branch 0 taken 2625 times.
✓ Branch 1 taken 562867 times.
565492 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3751 }
3752 else
3753 {
3754
4/4
✓ Branch 0 taken 1574 times.
✓ Branch 1 taken 555 times.
✓ Branch 2 taken 1562 times.
✓ Branch 3 taken 12 times.
3691 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
3755
3/4
✓ Branch 0 taken 1554 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 1554 times.
✗ Branch 3 not taken.
1562 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3756
3/4
✓ Branch 0 taken 1520 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 1520 times.
✗ Branch 3 not taken.
1554 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
3757
1/2
✓ Branch 0 taken 1520 times.
✗ Branch 1 not taken.
1520 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3758 }
3759 4615098 }
3760
3761 383430 bool enemy::isOnSideviewPlatform()
3762 {
3763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
3764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
3765
5/6
✓ Branch 0 taken 10306 times.
✓ Branch 1 taken 373124 times.
✓ Branch 2 taken 211 times.
✓ Branch 3 taken 10095 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 211 times.
383430 if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map
3766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383219 times.
383219 if(check_slope(x, y+1, usewid, usehei)) return true;
3767
2/2
✓ Branch 0 taken 383219 times.
✓ Branch 1 taken 168001 times.
551220 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
3768 {
3769
2/2
✓ Branch 0 taken 168001 times.
✓ Branch 1 taken 215218 times.
383219 if(_walkflag(nx,y+usehei,1)) return true;
3770
3/4
✓ Branch 0 taken 168001 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120644 times.
✓ Branch 3 taken 47357 times.
168001 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
3771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47357 times.
47357 if(checkSVLadderPlatform(nx,y+usehei)) return true;
3772 47357 }
3773 168001 return false;
3774 383430 }
3775
3776 // Stops playing the given sound only if there are no enemies left to play it
3777 370464 void enemy::stop_bgsfx(int32_t index)
3778 {
3779
2/2
✓ Branch 0 taken 361231 times.
✓ Branch 1 taken 9233 times.
370464 if(bgsfx<=0)
3780 361231 return;
3781
3782 // Look for other enemies with the same bgsfx
3783
2/2
✓ Branch 0 taken 38111 times.
✓ Branch 1 taken 5329 times.
43440 for(int32_t i=0; i<guys.Count(); i++)
3784 {
3785
4/4
✓ Branch 0 taken 31565 times.
✓ Branch 1 taken 6546 times.
✓ Branch 2 taken 3904 times.
✓ Branch 3 taken 27661 times.
38111 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
3786 3904 return;
3787 34207 }
3788
3789 5329 stop_sfx(bgsfx);
3790 370464 }
3791
3792
3793 // to allow for different sfx on defeating enemy
3794 18964 void enemy::death_sfx()
3795 {
3796
1/2
✓ Branch 0 taken 18964 times.
✗ Branch 1 not taken.
18964 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
3797 18964 }
3798
3799 void enemy::move(zfix dx,zfix dy)
3800 {
3801 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
3802 {
3803 switch(family)
3804 {
3805 case eeFIRE:
3806 case eeOTHER:
3807 return;
3808 default: break;
3809 }
3810 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
3811 }
3812 */
3813 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV) || !enemycanfall(id)))
3814 {
3815 x+=dx;
3816 y+=dy;
3817 }
3818 }
3819
3820 8900239 void enemy::move(zfix s)
3821 {
3822 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
3823 {
3824 switch(family)
3825 {
3826 case eeFIRE:
3827 case eeOTHER:
3828 return;
3829 default: break;
3830 }
3831 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
3832 }*/
3833
9/10
✓ Branch 0 taken 8900200 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 79762 times.
✓ Branch 3 taken 8820438 times.
✓ Branch 4 taken 40724 times.
✓ Branch 5 taken 39038 times.
✓ Branch 6 taken 855 times.
✓ Branch 7 taken 39869 times.
✓ Branch 8 taken 855 times.
✗ Branch 9 not taken.
8900239 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & FLAG_OBEYS_GRAV)))
3834 {
3835 8899345 sprite::move(s);
3836 8899345 }
3837 8900239 }
3838
3839 19615 void enemy::leave_item()
3840 {
3841 19615 int32_t drop_item = select_dropitem(item_set, x, y);
3842 19615 int32_t thedropset = item_set;
3843
3844 19615 std::vector<int32_t> &ev = FFCore.eventData;
3845 19615 ev.clear();
3846 19615 ev.push_back(getUID());
3847 19615 ev.push_back(drop_item*10000);
3848 19615 ev.push_back(thedropset*10000);
3849
3850 19615 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
3851 19615 drop_item = vbound(ev[1] / 10000,-2,255);
3852 19615 thedropset = ev[2] / 10000;
3853 19615 ev.clear();
3854
1/2
✓ Branch 0 taken 19615 times.
✗ Branch 1 not taken.
19615 if(drop_item == -2)
3855 {
3856 drop_item = select_dropitem(thedropset,x,y);
3857 }
3858
3859
6/6
✓ Branch 0 taken 7721 times.
✓ Branch 1 taken 11894 times.
✓ Branch 2 taken 357 times.
✓ Branch 3 taken 7364 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 333 times.
19615 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
3860 {
3861 item* itm;
3862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7697 times.
7697 if (get_bit(quest_rules, qr_ENEMY_DROPS_USE_HITOFFSETS))
3863 {
3864 itm = (new item(x+hxofs+(hxsz/2)-8,y+hyofs+(hysz/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
3865 }
3866 else
3867 {
3868
8/14
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 7414 times.
✓ Branch 2 taken 283 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 283 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 283 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 283 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 283 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 283 times.
✗ Branch 13 not taken.
7697 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
3869
4/8
✓ Branch 0 taken 7414 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7414 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7414 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7414 times.
✗ Branch 7 not taken.
7414 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
3870 }
3871 7697 itm->from_dropset = thedropset;
3872 7697 items.add(itm);
3873
3874 7697 ev.push_back(getUID());
3875 7697 ev.push_back(itm->getUID());
3876
3877 7697 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
3878 7697 ev.clear();
3879 7697 }
3880 19615 }
3881
3882 // auomatically kill off enemy (for rooms with ringleaders)
3883 290 void enemy::kickbucket()
3884 {
3885
2/2
✓ Branch 0 taken 265 times.
✓ Branch 1 taken 25 times.
290 if(!superman)
3886 265 hp=-1000; // don't call death_sfx()
3887 290 }
3888
3889 3278 bool enemy::isSubmerged() const
3890 {
3891 3278 return submerged;
3892 //!TODO SOLIDPUSH more things like teleporting wizzrobes
3893 }
3894
3895 17356 void enemy::FireBreath(bool seekhero)
3896 {
3897
1/2
✓ Branch 0 taken 17356 times.
✗ Branch 1 not taken.
17356 if(wpn==wNone)
3898 return;
3899
3900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17356 times.
17356 if(wpn==ewFireTrail)
3901 {
3902 dmisc1 = e1tEACHTILE;
3903 FireWeapon();
3904 return;
3905 }
3906
3907 17356 float fire_angle=0.0;
3908 17356 int32_t wx=0, wy=0, wdir=dir;
3909
3910
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 15704 times.
17356 if(!seekhero)
3911 {
3912
4/5
✓ Branch 0 taken 3271 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3038 times.
✓ Branch 3 taken 5264 times.
✓ Branch 4 taken 4131 times.
15704 switch(dir)
3913 {
3914 case down:
3915 3038 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
3916 3038 wx=x;
3917 3038 wy=y+8;
3918 3038 break;
3919
3920 case -1:
3921 case up:
3922 3271 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
3923 3271 wx=x;
3924 3271 wy=y-8;
3925 3271 break;
3926
3927 case left:
3928 5264 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
3929 5264 wx=x-8;
3930 5264 wy=y;
3931 5264 break;
3932
3933 case right:
3934 4131 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
3935 4131 wx=x+8;
3936 4131 wy=y;
3937 4131 break;
3938 }
3939
3940
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15704 if(wpn==ewFlame || wpn==ewFlame2)
3941 {
3942
2/4
✓ Branch 0 taken 15704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15704 times.
15704 if(fire_angle==-PI || fire_angle==PI) wdir=left;
3943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==-PI/2) wdir=up;
3944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==PI/2) wdir=down;
3945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==0) wdir=right;
3946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<-PI/2) wdir=l_up;
3947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<0) wdir=r_up;
3948
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14206 times.
15704 else if(fire_angle<(PI/2)) wdir=r_down;
3949
2/2
✓ Branch 0 taken 10090 times.
✓ Branch 1 taken 4116 times.
14206 else if(fire_angle<PI) wdir=l_down;
3950 15704 }
3951 15704 }
3952 else
3953 {
3954 1652 wx = x;
3955 1652 wy = y;
3956 }
3957
3958
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 15704 times.
17356 addEwpn(wx,wy,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
3959 17356 sfx(wpnsfx(wpn),pan(int32_t(x)));
3960
3961 17356 int32_t i=Ewpns.Count()-1;
3962 17356 weapon *ew = (weapon*)(Ewpns.spr(i));
3963 17356 ew->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
3964
3965
4/4
✓ Branch 0 taken 15704 times.
✓ Branch 1 taken 1652 times.
✓ Branch 2 taken 7830 times.
✓ Branch 3 taken 7874 times.
17356 if(!seekhero && (zc_oldrand()&4))
3966 {
3967 7874 ew->angular=true;
3968 7874 ew->angle=fire_angle;
3969 7874 }
3970
3971
4/4
✓ Branch 0 taken 17299 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 16982 times.
17356 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
3972 {
3973 16982 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
3974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16982 times.
16982 if ( ew->do_animation ) ew->tile+=ew->aframe;
3975 16982 }
3976
3977
2/2
✓ Branch 0 taken 17356 times.
✓ Branch 1 taken 542966 times.
560322 for(int32_t j=Ewpns.Count()-1; j>0; j--)
3978 {
3979 542966 Ewpns.swap(j,j-1);
3980 542966 }
3981 17356 }
3982
3983 24452 void enemy::FireWeapon()
3984 {
3985 /*
3986 * Type:
3987 * 0x01: Boss fireball
3988 * 0x02: Seeks Hero
3989 * 0x04: Fast projectile
3990 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
3991 */
3992
3993
1/2
✓ Branch 0 taken 24452 times.
✗ Branch 1 not taken.
24452 if (wpn < 1) return;
3994
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 24452 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
24452 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
3995 return;
3996
3997
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24452 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24452 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
3998 dmisc1 = e1tEACHTILE;
3999
4000 24452 int32_t xoff = 0;
4001 24452 int32_t yoff = 0;
4002
1/2
✓ Branch 0 taken 24452 times.
✗ Branch 1 not taken.
24452 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
4003 {
4004 xoff += (hxsz/2)-8;
4005 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
4006 }
4007
1/2
✓ Branch 0 taken 24452 times.
✗ Branch 1 not taken.
24452 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
4008 {
4009 yoff += (hysz/2)-8;
4010 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
4011 }
4012
4013
4/8
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 23041 times.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
24452 switch(dmisc1)
4014 {
4015 case e1t5SHOTS: //BS-Aquamentus
4016 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
4017 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4018 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
4019 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4020
4021 [[fallthrough]];
4022 case e1t3SHOTSFAST:
4023 case e1t3SHOTS: //Aquamentus
4024
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
4025 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4026
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
4027 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4028
4029 [[fallthrough]];
4030 default:
4031
11/20
✓ Branch 0 taken 23454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23454 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23454 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 23454 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 23454 times.
✓ Branch 12 taken 23454 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 10905 times.
✓ Branch 15 taken 12549 times.
✓ Branch 16 taken 23454 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 23454 times.
✗ Branch 19 not taken.
23454 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
4032 23454 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4033 23454 sfx(wpnsfx(wpn),pan(int32_t(x)));
4034 23454 break;
4035
4036 case e1tSLANT:
4037 {
4038 409 int32_t slant = 0;
4039
4040
10/10
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 197 times.
✓ Branch 3 taken 212 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 152 times.
✓ Branch 6 taken 60 times.
✓ Branch 7 taken 304 times.
✓ Branch 8 taken 131 times.
✓ Branch 9 taken 173 times.
409 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
4041 236 slant = left;
4042
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 109 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 51 times.
✓ Branch 7 taken 85 times.
✓ Branch 8 taken 24 times.
✓ Branch 9 taken 61 times.
173 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
4043 112 slant = right;
4044
4045
9/18
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 319 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 319 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 319 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 319 times.
✓ Branch 14 taken 319 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 319 times.
✗ Branch 17 not taken.
319 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
4046 319 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4047 319 sfx(wpnsfx(wpn),pan(int32_t(x)));
4048 319 break;
4049 }
4050
4051 case e1t8SHOTS: //Fire Wizzrobe
4052 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
4053 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4054 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4055 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
4056 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4057 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4058 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
4059 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4060 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4061 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
4062 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4063 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4064
4065 [[fallthrough]];
4066 case e1t4SHOTS: //Stalfos 3
4067
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
4068 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4069 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4070
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
4071 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4072 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4073
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
4074 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4075 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4076
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
4077 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4078 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4079 589 sfx(wpnsfx(wpn),pan(int32_t(x)));
4080 589 break;
4081
4082 case e1tSUMMON: // Bat Wizzrobe
4083 {
4084 //al_trace("Summon Bats\n");
4085 //zprint2("Summon Bats\n");
4086 if(dmisc4==0) break; // Summon 0
4087
4088 int32_t bc=0;
4089
4090 for(int32_t gc=0; gc<guys.Count(); gc++)
4091 {
4092 if((((enemy*)guys.spr(gc))->id) == dmisc3)
4093 {
4094 ++bc;
4095 }
4096 }
4097
4098 if(bc<=40) // Not too many enemies
4099 {
4100 int32_t kids = guys.Count();
4101 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
4102
4103 for(int32_t i=0; i<bats; i++)
4104 {
4105 //zprint2("summon\n");
4106 //al_trace("summon\n");
4107 if(addchild(x,y,dmisc3,-10, this->script_UID))
4108 {
4109 ((enemy*)guys.spr(kids+i))->count_enemy = false;
4110 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
4111 //zprint2("Summoner Script UID: %d\n",this->script_UID);
4112
4113 }
4114 }
4115
4116 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
4117 }
4118
4119 break;
4120 }
4121
4122 case e1tSUMMONLAYER: // Summoner
4123 {
4124 if(count_layer_enemies()==0)
4125 {
4126 break;
4127 }
4128
4129 int32_t kids = guys.Count();
4130
4131 if(kids<40)
4132 {
4133 int32_t newguys=(zc_oldrand()%3)+1;
4134 bool summoned=false;
4135
4136 for(int32_t i=0; i<newguys; i++)
4137 {
4138 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
4139 int32_t x2=0;
4140 int32_t y2=0;
4141
4142 for(int32_t k=0; k<20; ++k)
4143 {
4144 x2=16*((zc_oldrand()%12)+2);
4145 y2=16*((zc_oldrand()%7)+2);
4146
4147 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
4148 {
4149 //zprint2("summon\n");
4150 //al_trace("summon\n");
4151 if(addchild(x2,y2,get_bit(quest_rules,qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
4152 {
4153 ((enemy*)guys.spr(kids+i))->count_enemy = false;
4154 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
4155 if (get_bit(quest_rules,qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
4156 {
4157 ((enemy*)guys.spr(kids+i))->fakez = 64;
4158 ((enemy*)guys.spr(kids+i))->z = 0;
4159 }
4160 }
4161
4162 summoned=true;
4163 break;
4164 }
4165 }
4166 }
4167
4168 if(summoned)
4169 {
4170 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
4171 }
4172 }
4173
4174 break;
4175 }
4176 }
4177 24362 }
4178
4179
4180 // Hit the shield(s)?
4181 // Apparently, this function is only used for hookshots...
4182 389 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
4183 {
4184
4/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 283 times.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 106 times.
389 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
4185 106 return false;
4186
4187 283 bool ret = false;
4188
4189 // TODO: There must be some bitwise operations that can simplify this...
4190
9/12
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 146 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 123 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 129 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 129 times.
✓ Branch 10 taken 129 times.
✗ Branch 11 not taken.
283 if(wpny > y) ret = ((flags&inv_front && xdir==down) || (flags&inv_back && xdir==up) || (flags&inv_left && xdir==left) || (flags&inv_right && xdir==right));
4191
9/12
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 82 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 94 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
146 else if(wpny < y) ret = ((flags&inv_front && xdir==up) || (flags&inv_back && xdir==down) || (flags&inv_left && xdir==right) || (flags&inv_right && xdir==left));
4192
4193
11/14
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 182 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 101 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 89 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 95 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 95 times.
✓ Branch 12 taken 95 times.
✗ Branch 13 not taken.
291 if(wpnx < x) ret = ret || ((flags&inv_front && xdir==left) || (flags&inv_back && xdir==right) || (flags&inv_left && xdir==up) || (flags&inv_right && xdir==down));
4194
10/14
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 141 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 138 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 138 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 138 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 138 times.
182 else if(wpnx > x) ret = ret || ((flags&inv_front && xdir==right) || (flags&inv_back && xdir==left) || (flags&inv_left && xdir==down) || (flags&inv_right && xdir==up));
4195
4196 291 return ret;
4197 397 }
4198
4199
4200 //! Weapon Editor for 2.6
4201 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
4202
4203
4204 //converts a wqeapon ID to its defence index.
4205 64239 int32_t weaponToDefence(int32_t wid)
4206 {
4207
20/44
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 29714 times.
✓ Branch 3 taken 6677 times.
✓ Branch 4 taken 16321 times.
✓ Branch 5 taken 650 times.
✓ Branch 6 taken 27 times.
✓ Branch 7 taken 48 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 948 times.
✓ Branch 10 taken 5722 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 163 times.
✓ Branch 14 taken 726 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 322 times.
✓ Branch 18 taken 920 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 180 times.
✓ Branch 21 taken 397 times.
✓ Branch 22 taken 118 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 254 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 11 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 12 times.
✓ Branch 34 taken 77 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 952 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
64239 switch(wid)
4208 {
4209 case wNone: return -1;
4210 29714 case wSword: return edefSWORD;
4211 6677 case wBeam: return edefBEAM;
4212 16321 case wBrang: return edefBRANG;
4213 650 case wBomb: return edefBOMB;
4214 27 case wSBomb: return edefSBOMB;
4215 48 case wLitBomb: return edefBOMB;
4216 case wLitSBomb: return edefSBOMB;
4217 948 case wArrow: return edefARROW;
4218 5722 case wFire: return edefFIRE;
4219 case wWhistle:
4220 {
4221 //al_trace("Weapon resolved as a whistle, using edef: %s\n", "edefWhistle");
4222 return edefWhistle;
4223 }
4224 case wBait: return edefBAIT;
4225 163 case wWand: return edefWAND;
4226 726 case wMagic: return edefMAGIC;
4227 case wCatching: return -1;
4228 case wWind: return edefWIND;
4229 322 case wRefMagic: return edefREFMAGIC;
4230 920 case wRefFireball: return edefREFBALL;
4231 case wRefRock: return edefREFROCK;
4232 180 case wHammer: return edefHAMMER;
4233 397 case wHookshot: return edefHOOKSHOT;
4234 118 case wHSHandle: return edefHOOKSHOT;
4235 case wHSChain: return edefHOOKSHOT;
4236 case wSSparkle: return edefSPARKLE;
4237 254 case wFSparkle: return edefSPARKLE;
4238 case wSmack: return -1; // is this the candle object?
4239 case wPhantom: return -1; //engine created visual effects.
4240 case wCByrna: return edefBYRNA;
4241 11 case wRefBeam: return edefREFBEAM;
4242 case wStomp: return edefSTOMP;
4243 case wScript1: return edefSCRIPT01;
4244 case wScript2: return edefSCRIPT02;
4245 12 case wScript3: return edefSCRIPT03;
4246 77 case wScript4: return edefSCRIPT04;
4247 case wScript5: return edefSCRIPT05;
4248 case wScript6: return edefSCRIPT06;
4249 case wScript7: return edefSCRIPT07;
4250 case wScript8: return edefSCRIPT08;
4251 case wScript9: return edefSCRIPT09;
4252 952 case wScript10: return edefSCRIPT10;
4253 case wIce: return edefICE;
4254 case wSound: return edefSONIC;
4255 case wThrown: return edefTHROWN;
4256 //case wPot: return edefPOT;
4257 // case wLitZap: return edefELECTRIC;
4258 // case wZ3Sword: return edefZ3SWORD;
4259 // case wLASWord: return edefLASWORD;
4260 // case wSpinAttk: return edefSPINATTK;
4261 // case wShield: return edefSHIELD;
4262 // case wTrowel: return edefTROWEL;
4263
4264 default: return -1;
4265 }
4266 64239 }
4267
4268 64239 int32_t getDefType(weapon *w)
4269 {
4270 64239 int32_t id = getWeaponID(w);
4271 64239 int32_t edef = weaponToDefence(id);
4272
2/2
✓ Branch 0 taken 63724 times.
✓ Branch 1 taken 515 times.
64239 if(edef == edefHOOKSHOT)
4273 {
4274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515 times.
515 if(w->family_class == itype_switchhook)
4275 return edefSwitchHook;
4276 515 }
4277 64239 return edef;
4278 64239 }
4279
4280 111760 int32_t getWeaponID(weapon *w)
4281 {
4282 111760 int32_t usewpn = w->useweapon;
4283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111760 times.
111760 return (usewpn > 0) ? usewpn : w->id;
4284 }
4285
4286 64239 int32_t enemy::resolveEnemyDefence(weapon *w)
4287 {
4288 //sword edef is 9, but we're reading it at 0
4289 //,
4290 64239 int32_t weapondef = 0;
4291 64239 int32_t wdeftype = getDefType(w);
4292 64239 int32_t usedef = w->usedefence;
4293
4294
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 64239 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
64239 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
4295 {
4296 weapondef = usedef*-1;
4297 }
4298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64239 times.
64239 else if(unsigned(wdeftype) < edefLAST255)
4299 {
4300 64239 weapondef = wdeftype;
4301 64239 }
4302 64239 return weapondef;
4303 }
4304
4305 69652 byte get_def_ignrflag(int32_t edef)
4306 {
4307
3/3
✓ Branch 0 taken 58472 times.
✓ Branch 1 taken 2050 times.
✓ Branch 2 taken 9130 times.
69652 switch(edef)
4308 {
4309 case edIGNORE:
4310 case edIGNOREL1:
4311 case edSTUNORIGNORE:
4312 9130 return WPNUNB_IGNR;
4313 case edSTUNORCHINK:
4314 case edCHINK:
4315 case edCHINKL1:
4316 case edCHINKL2:
4317 case edCHINKL4:
4318 case edCHINKL6:
4319 case edCHINKL8:
4320 case edCHINKL10:
4321 case edLEVELCHINK2:
4322 case edLEVELCHINK3:
4323 case edLEVELCHINK4:
4324 case edLEVELCHINK5:
4325 2050 return WPNUNB_BLOCK;
4326 }
4327 58472 return 0;
4328 69652 }
4329
4330 69652 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
4331 {
4332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69652 times.
69652 if(!(unblockable&get_def_ignrflag(edef))) return edef;
4333 switch(edef)
4334 {
4335 case edIGNORE:
4336 case edIGNOREL1:
4337 case edCHINK:
4338 case edCHINKL1:
4339 case edCHINKL2:
4340 case edCHINKL4:
4341 case edCHINKL6:
4342 case edCHINKL8:
4343 case edCHINKL10:
4344 case edLEVELCHINK2:
4345 case edLEVELCHINK3:
4346 case edLEVELCHINK4:
4347 case edLEVELCHINK5:
4348 return edNORMAL;
4349 case edSTUNORIGNORE:
4350 case edSTUNORCHINK:
4351 return edSTUNONLY;
4352 }
4353 return edef;
4354 69652 }
4355
4356 // Do we do damage?
4357 // 0: takehit returns 0
4358 // 1: takehit returns 1
4359 // -1: do damage
4360 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
4361 63287 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
4362 {
4363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63287 times.
63287 if(switch_hooked) return 0;
4364 63287 int32_t tempx = x;
4365 63287 int32_t tempy = y;
4366 63287 int32_t the_defence = 0;
4367
1/2
✓ Branch 0 taken 63287 times.
✗ Branch 1 not taken.
63287 if ( edef < 0 ) //we are using a specific base default defence for a weapon
4368 {
4369 the_defence = edef*-1; //A specific defence type.
4370 }
4371 63287 else the_defence = defense[edef];
4372
4373 63287 the_defence = conv_edef_unblockable(the_defence, unblockable);
4374
4375
3/4
✓ Branch 0 taken 4124 times.
✓ Branch 1 taken 59163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4124 times.
63287 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
4376 {
4377
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4123 times.
✓ Branch 2 taken 1 times.
4124 switch(the_defence)
4378 {
4379 case edIGNORE:
4380 1 return 0;
4381 case edIGNOREL1:
4382 case edSTUNORIGNORE:
4383 if(*power <= 0)
4384 return 0;
4385 }
4386 4123 sfx(WAV_CHINK,pan(int32_t(x)));
4387 4123 return 1;
4388 }
4389
4390 59163 int32_t new_id = id;
4391 59163 int32_t effect_type = dmisc15;
4392 59163 int32_t delay_timer = 90;
4393 59163 enemy *gleeok = NULL;
4394 59163 enemy *ptra = NULL;
4395 59163 int32_t c = 0;
4396
4397
15/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 284 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1328 times.
✓ Branch 6 taken 581 times.
✓ Branch 7 taken 21 times.
✓ Branch 8 taken 80 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 179 times.
✓ Branch 13 taken 7801 times.
✓ Branch 14 taken 135 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1554 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 79 times.
✓ Branch 26 taken 58 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 46976 times.
59163 switch(the_defence)
4398 {
4399 case edREPLACE:
4400 {
4401 sclk = 0;
4402 if ( dmisc16 > 0 ) new_id = dmisc16;
4403 else new_id = id+1;
4404 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
4405 if ( dmisc17 > 0 ) delay_timer = dmisc17;
4406 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
4407
4408 //Z_scripterrlog("new id is %d\n", new_id);
4409 switch(guysbuf[new_id&0xFFF].family)
4410 {
4411 //Fixme: possible enemy memory leak. (minor)
4412 case eeWALK:
4413 {
4414 enemy *e = new eStalfos(x,y,new_id,clk);
4415 guys.add(e);
4416 }
4417 break;
4418
4419 case eeLEV:
4420 {
4421 enemy *e = new eLeever(x,y,new_id,clk);
4422 guys.add(e);
4423 }
4424 break;
4425
4426 case eeTEK:
4427 {
4428 enemy *e = new eTektite(x,y,new_id,clk);
4429 guys.add(e);
4430 }
4431 break;
4432
4433 case eePEAHAT:
4434 {
4435 enemy *e = new ePeahat(x,y,new_id,clk);
4436 guys.add(e);
4437 }
4438 break;
4439
4440 case eeZORA:
4441 {
4442 enemy *e = new eZora(x,y,new_id,clk);
4443 guys.add(e);
4444 }
4445 break;
4446
4447 case eeGHINI:
4448 {
4449 enemy *e = new eGhini(x,y,new_id,clk);
4450 guys.add(e);
4451 }
4452 break;
4453
4454 case eeKEESE:
4455 {
4456 enemy *e = new eKeese(x,y,new_id,clk);
4457 guys.add(e);
4458 }
4459 break;
4460
4461 case eeWIZZ:
4462 {
4463 enemy *e = new eWizzrobe(x,y,new_id,clk);
4464 guys.add(e);
4465 }
4466 break;
4467
4468 case eePROJECTILE:
4469 {
4470 enemy *e = new eProjectile(x,y,new_id,clk);
4471 guys.add(e);
4472 }
4473 break;
4474
4475 case eeWALLM:
4476 {
4477 enemy *e = new eWallM(x,y,new_id,clk);
4478 guys.add(e);
4479 }
4480 break;
4481
4482 case eeAQUA:
4483 {
4484 enemy *e = new eAquamentus(x,y,new_id,clk);
4485 guys.add(e);
4486 e->x = x;
4487 e->y = y;
4488 }
4489 break;
4490
4491 case eeMOLD:
4492 {
4493 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1)));
4494 guys.add(e);
4495 e->x = x;
4496 e->y = y;
4497 }
4498 break;
4499
4500 case eeMANHAN:
4501 {
4502 enemy *e = new eManhandla(x,y,new_id,clk);
4503 guys.add(e);
4504 e->x = x;
4505 e->y = y;
4506 }
4507 break;
4508
4509 case eeGLEEOK:
4510 {
4511 *power = 0;
4512 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].misc1);
4513 guys.add(gleeok);
4514 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
4515 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
4516 new_id &= 0xFFF;
4517 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
4518 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
4519 for(int32_t i=0; i<head_cnt; i++)
4520 {
4521 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
4522 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
4523 {
4524 al_trace("Gleeok head %d could not be created!\n",i+1);
4525
4526 for(int32_t j=0; j<i+1; j++)
4527 {
4528 guys.del(guys.Count()-1);
4529 }
4530
4531 break;
4532 }
4533 else
4534 {
4535 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
4536 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
4537 }
4538
4539 c-=guysbuf[new_id].misc4;
4540 //gleeok->x = x;
4541 //gleeok->y = y;
4542 //gleeok = e;
4543 }
4544 return 1;
4545 }
4546
4547 case eeGHOMA:
4548 {
4549 enemy *e = new eGohma(x,y,new_id,clk);
4550 guys.add(e);
4551 e->x = x;
4552 e->y = y;
4553 }
4554 break;
4555
4556 case eeLANM:
4557 {
4558 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)));
4559 guys.add(e);
4560 e->x = x;
4561 e->y = y;
4562 }
4563 break;
4564
4565 case eeGANON:
4566 {
4567 enemy *e = new eGanon(x,y,new_id,clk);
4568 guys.add(e);
4569 e->x = x;
4570 e->y = y;
4571 }
4572 break;
4573
4574 case eeFAIRY:
4575 {
4576 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
4577 guys.add(e);
4578 e->x = x;
4579 e->y = y;
4580 }
4581 break;
4582
4583 case eeFIRE:
4584 {
4585 enemy *e = new eFire(x,y,new_id,clk);
4586 guys.add(e);
4587 e->x = x;
4588 e->y = y;
4589 }
4590 break;
4591
4592 case eeOTHER:
4593 {
4594 enemy *e = new eOther(x,y,new_id,clk);
4595 guys.add(e);
4596 e->x = x;
4597 e->y = y;
4598 }
4599 break;
4600
4601 case eeSPINTILE:
4602 {
4603 enemy *e = new eSpinTile(x,y,new_id,clk);
4604 guys.add(e);
4605 e->x = x;
4606 e->y = y;
4607 }
4608 break;
4609
4610 // and these enemies use the misc10/misc2 value
4611 case eeROCK:
4612 {
4613 switch(guysbuf[new_id&0xFFF].misc10)
4614 {
4615 case 1:
4616 {
4617 enemy *e = new eBoulder(x,y,new_id,clk);
4618 guys.add(e);
4619 e->x = x;
4620 e->y = y;
4621 }
4622 break;
4623
4624 case 0:
4625 default:
4626 {
4627 enemy *e = new eRock(x,y,new_id,clk);
4628 guys.add(e);
4629 e->x = x;
4630 e->y = y;
4631 }
4632 break;
4633 }
4634
4635 break;
4636 }
4637
4638 case eeTRAP:
4639 {
4640 switch(guysbuf[new_id&0xFFF].misc2)
4641 {
4642 case 1:
4643 {
4644 enemy *e = new eTrap2(x,y,new_id,clk);
4645 guys.add(e);
4646 e->x = x;
4647 e->y = y;
4648 }
4649 break;
4650
4651 case 0:
4652 default:
4653 {
4654 enemy *e = new eTrap(x,y,new_id,clk);
4655 guys.add(e);
4656 e->x = x;
4657 e->y = y;
4658 }
4659 break;
4660 }
4661
4662 break;
4663 }
4664
4665 case eeDONGO:
4666 {
4667 switch(guysbuf[new_id&0xFFF].misc10)
4668 {
4669 case 1:
4670 {
4671 enemy *e = new eDodongo2(x,y,new_id,clk);
4672 guys.add(e);
4673 e->x = x;
4674 e->y = y;
4675 }
4676 break;
4677
4678 case 0:
4679 default:
4680 {
4681 enemy *e = new eDodongo(x,y,new_id,clk);
4682 guys.add(e);
4683 e->x = x;
4684 e->y = y;
4685 }
4686 break;
4687 }
4688
4689 break;
4690 }
4691
4692 case eeDIG:
4693 {
4694 switch(guysbuf[new_id&0xFFF].misc10)
4695 {
4696 case 1:
4697 {
4698 enemy *e = new eLilDig(x,y,new_id,clk);
4699 guys.add(e);
4700 e->x = x;
4701 e->y = y;
4702 }
4703 break;
4704
4705 case 0:
4706 default:
4707 {
4708 enemy *e = new eBigDig(x,y,new_id,clk);
4709 guys.add(e);
4710 e->x = x;
4711 e->y = y;
4712 }
4713 break;
4714 }
4715
4716 break;
4717 }
4718
4719 case eePATRA:
4720 {
4721 switch(guysbuf[new_id&0xFFF].misc10)
4722 {
4723 case 1:
4724 {
4725 if (get_bit(quest_rules,qr_HARDCODED_BS_PATRA))
4726 {
4727 enemy *e = new ePatraBS(x,y,new_id,clk);
4728 guys.add(e);
4729 e->x = x;
4730 e->y = y;
4731 break;
4732 }
4733 }
4734 [[fallthrough]];
4735 case 0:
4736 default:
4737 {
4738 enemy *e = new ePatra(x,y,new_id,clk);
4739 guys.add(e);
4740 e->x = x;
4741 e->y = y;
4742 }
4743 break;
4744 }
4745
4746 break;
4747 }
4748
4749 case eeGUY:
4750 {
4751 switch(guysbuf[new_id&0xFFF].misc10)
4752 {
4753 case 1:
4754 {
4755 enemy *e = new eTrigger(x,y,new_id,clk);
4756 guys.add(e);
4757 }
4758 break;
4759
4760 case 0:
4761 default:
4762 {
4763 enemy *e = new eNPC(x,y,new_id,clk);
4764 guys.add(e);
4765 }
4766 break;
4767 }
4768
4769 break;
4770 }
4771
4772 case eeSCRIPT01:
4773 case eeSCRIPT02:
4774 case eeSCRIPT03:
4775 case eeSCRIPT04:
4776 case eeSCRIPT05:
4777 case eeSCRIPT06:
4778 case eeSCRIPT07:
4779 case eeSCRIPT08:
4780 case eeSCRIPT09:
4781 case eeSCRIPT10:
4782 case eeSCRIPT11:
4783 case eeSCRIPT12:
4784 case eeSCRIPT13:
4785 case eeSCRIPT14:
4786 case eeSCRIPT15:
4787 case eeSCRIPT16:
4788 case eeSCRIPT17:
4789 case eeSCRIPT18:
4790 case eeSCRIPT19:
4791 case eeSCRIPT20:
4792 {
4793 enemy *e = new eScript(x,y,new_id,clk);
4794 guys.add(e);
4795 e->x = x;
4796 e->y = y;
4797 break;
4798 }
4799
4800
4801 case eeFFRIENDLY01:
4802 case eeFFRIENDLY02:
4803 case eeFFRIENDLY03:
4804 case eeFFRIENDLY04:
4805 case eeFFRIENDLY05:
4806 case eeFFRIENDLY06:
4807 case eeFFRIENDLY07:
4808 case eeFFRIENDLY08:
4809 case eeFFRIENDLY09:
4810 case eeFFRIENDLY10:
4811 {
4812 enemy *e = new eFriendly(x,y,new_id,clk);
4813 guys.add(e);
4814 e->x = x;
4815 e->y = y;
4816 break;
4817 }
4818
4819
4820 default: break;
4821 }
4822
4823 // add segments of segmented enemies
4824 int32_t c=0;
4825
4826 switch(guysbuf[new_id&0xFFF].family)
4827 {
4828 case eeMOLD:
4829 {
4830 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
4831 new_id &= 0xFFF;
4832
4833 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].misc1)); i++)
4834 {
4835 //christ this is messy -DD
4836 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
4837
4838 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
4839 {
4840 al_trace("Moldorm segment %d could not be created!\n",i+1);
4841
4842 for(int32_t j=0; j<i+1; j++)
4843 guys.del(guys.Count()-1);
4844
4845 return 0;
4846 }
4847
4848 if(i>0)
4849 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
4850
4851
4852 }
4853
4854 break;
4855 }
4856
4857 case eeLANM:
4858 {
4859 new_id &= 0xFFF;
4860 int32_t shft = guysbuf[new_id].misc2;
4861 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
4862 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
4863
4864 if(!guys.add(e))
4865 {
4866 al_trace("Lanmola segment 1 could not be created!\n");
4867 guys.del(guys.Count()-1);
4868 return 0;
4869 }
4870 e->x = x;
4871 e->y = y;
4872
4873
4874
4875 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)); i++)
4876 {
4877 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
4878 if(!guys.add(e2))
4879 {
4880 al_trace("Lanmola segment %d could not be created!\n",i+1);
4881
4882 for(int32_t j=0; j<i+1; j++)
4883 guys.del(guys.Count()-1);
4884
4885 return 0;
4886 }
4887 e2->x = x;
4888 e2->y = y;
4889
4890 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
4891
4892 }
4893 }
4894 break;
4895
4896 case eeMANHAN:
4897 new_id &= 0xFFF;
4898
4899 for(int32_t i=0; i<((!(guysbuf[new_id].misc2))?4:8); i++)
4900 {
4901 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
4902 {
4903 al_trace("Manhandla head %d could not be created!\n",i+1);
4904
4905 for(int32_t j=0; j<i+1; j++)
4906 {
4907 guys.del(guys.Count()-1);
4908 }
4909
4910 return 0;
4911 }
4912
4913
4914 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].misc1;
4915 }
4916
4917 break;
4918
4919 case eeGLEEOK:
4920 {
4921 /*
4922 new_id &= 0xFFF;
4923 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
4924 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
4925 for(int32_t i=0; i<head_cnt; i++)
4926 {
4927 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
4928 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
4929 {
4930 al_trace("Gleeok head %d could not be created!\n",i+1);
4931
4932 for(int32_t j=0; j<i+1; j++)
4933 {
4934 guys.del(guys.Count()-1);
4935 }
4936
4937 break;
4938 }
4939
4940 c-=guysbuf[new_id].misc4;
4941 */
4942
4943 // }
4944 }
4945 break;
4946
4947
4948 case eePATRA:
4949 {
4950 new_id &= 0xFFF;
4951 int32_t outeyes = 0;
4952 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
4953
4954 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc1); i++)
4955 {
4956 if(!((guysbuf[new_id].misc10&&get_bit(quest_rules,qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
4957 {
4958 al_trace("Patra outer eye %d could not be created!\n",i+1);
4959
4960 for(int32_t j=0; j<i+1; j++)
4961 guys.del(guys.Count()-1);
4962
4963 return 0;
4964 }
4965 else
4966 outeyes++;
4967
4968
4969 }
4970
4971 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc2); i++)
4972 {
4973 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
4974 {
4975 al_trace("Patra inner eye %d could not be created!\n",i+1);
4976
4977 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
4978 guys.del(guys.Count()-1);
4979
4980 return 0;
4981 }
4982
4983
4984 }
4985 delete ptra;
4986 break;
4987 }
4988 }
4989
4990
4991
4992 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
4993 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
4994 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
4995 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
4996 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
4997 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
4998 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
4999 //((enemy*)guys.spr(guys.Count()-1))->mainguy = this->mainguy; //This might mean that it is a core.
5000 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
5001 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
5002 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
5003 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
5004 ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID;
5005 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
5006
5007
5008 item_set = 0; //Do not make a drop.
5009
5010 switch(effect_type)
5011 {
5012 case -7:
5013 {
5014 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
5015 Lwpns.add(w);
5016 break;
5017 }
5018 case -6:
5019 {
5020 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
5021 Lwpns.add(w);
5022 break;
5023 }
5024 case -5:
5025 {
5026 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
5027 Lwpns.add(w);
5028 break;
5029 }
5030 case -4:
5031 {
5032 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
5033 Lwpns.add(w);
5034 break;
5035 }
5036 case -3: explode(1); break;
5037 case -2: explode(2); break;
5038 case -1: explode(0); break;
5039 case 0: break;
5040
5041 default:
5042 {
5043 //Dummy weapon function
5044 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
5045 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
5046 Lwpns.add(w);
5047 break;
5048 }
5049 }
5050
5051
5052 yofs = -32768;
5053 switch(guysbuf[new_id&0xFFF].family)
5054 {
5055 case eeGLEEOK:
5056 {
5057 Z_scripterrlog("Replacing a gleeok.\n");
5058 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
5059 hp = -999;
5060 tempenemy->hp = -999;
5061 break;
5062
5063 }
5064 default:
5065 hp = -1000; break;
5066 }
5067 ++game->guys[(currmap*MAPSCRSNORMAL)+currscr];
5068 return 1;
5069
5070 }
5071 case edSPLIT:
5072 {
5073 //int32_t ex = x; int32_t ey = y;
5074 //al_trace("edSplit dmisc3: %d\n", dmisc3);
5075 //al_trace("edSplit dmisc4: %d\n", dmisc4);
5076 /*
5077 if ( txsx > 1 )
5078 {
5079 ex += ( txsz-1 ) * 8; //from its middle
5080 }
5081 if ( tysx > 1 )
5082 {
5083 ey += ( tysz-1 ) * 8; //from its middle
5084 }
5085 */
5086 for ( int32_t q = 0; q < dmisc4; q++ )
5087 {
5088
5089 //addenemy((x+(txsz*16)/2),(y+(tysz*16)/2),dmisc3+0x1000,-15);
5090 addenemy(
5091 //ex,ey,
5092 x,y,
5093 dmisc3+0x1000,-15);
5094 //addenemy(ex,ey,dmisc3,0);
5095
5096 }
5097 item_set = 0; //Do not make a drop.
5098 hp = -1000;
5099 return -1;
5100
5101 }
5102 case edSUMMON:
5103 {
5104
5105
5106 //al_trace("edSplit dmisc3: %d\n", dmisc3);
5107 //al_trace("edSplit dmisc4: %d\n", dmisc4);
5108 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
5109 for ( int32_t q = 0; q < summon_count; q++ )
5110 {
5111 int32_t x2=16*((zc_oldrand()%12)+2);
5112 int32_t y2=16*((zc_oldrand()%7)+2);
5113 addenemy(
5114 //(x+(txsz*16)/2),(y+(tysz*16)/2)
5115 x2,y2,
5116 dmisc3+0x1000,-15);
5117 //addenemy(ex,ey,dmisc3,0);
5118
5119 }
5120 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
5121 return -1;
5122
5123 }
5124
5125 case edEXPLODESMALL:
5126 {
5127 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
5128 Ewpns.add(ew);
5129 item_set = 0; //Should we make a drop?
5130 hp = -1000;
5131 return -1;
5132 }
5133
5134
5135 case edEXPLODEHARMLESS:
5136 {
5137 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
5138 Ewpns.add(ew);
5139 ew->hyofs = -32768;
5140 item_set = 0; //Should we make a drop?
5141 hp = -1000;
5142 return -1;
5143 }
5144
5145
5146 case edEXPLODELARGE:
5147 {
5148 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
5149 Ewpns.add(ew);
5150
5151 hp = -1000;
5152 return -1;
5153 }
5154
5155
5156 case edTRIGGERSECRETS:
5157 {
5158 hidden_entrance(0, true, false, -4);
5159 return -1;
5160 }
5161
5162 case edSTUNORCHINK:
5163
3/4
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 804 times.
✓ Branch 2 taken 750 times.
✗ Branch 3 not taken.
2597 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK))
5164 {
5165 sfx(WAV_CHINK,pan(int32_t(x)));
5166 return 1;
5167 }
5168
2/2
✓ Branch 0 taken 511 times.
✓ Branch 1 taken 1043 times.
1554 else if(*power <= 0)
5169 {
5170 //al_trace("defendNew() is at: %s\n", "returning edSTUNORCHINK");
5171 511 sfx(WAV_CHINK,pan(int32_t(x)));
5172 511 return 1;
5173 }
5174 [[fallthrough]];
5175
5176 case edSTUNORIGNORE:
5177
3/4
✓ Branch 0 taken 1240 times.
✓ Branch 1 taken 1131 times.
✓ Branch 2 taken 1240 times.
✗ Branch 3 not taken.
4023 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK))
5178 {
5179 sfx(WAV_CHINK,pan(int32_t(x)));
5180 return 1;
5181 }
5182
2/2
✓ Branch 0 taken 719 times.
✓ Branch 1 taken 1652 times.
2371 else if(*power <= 0)
5183 719 return 0;
5184 [[fallthrough]];
5185
5186 case edSTUNONLY:
5187
7/10
✓ Branch 0 taken 2233 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2233 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2233 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2177 times.
✓ Branch 7 taken 56 times.
✓ Branch 8 taken 2204 times.
✓ Branch 9 taken 29 times.
2233 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
5188 {
5189 //al_trace("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
5190 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
5191 29 return 1;
5192 }
5193
3/4
✓ Branch 0 taken 1629 times.
✓ Branch 1 taken 575 times.
✓ Branch 2 taken 1629 times.
✗ Branch 3 not taken.
2204 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK))
5194 {
5195 sfx(WAV_CHINK,pan(int32_t(x)));
5196 return 1;
5197 }
5198 else
5199 {
5200 2204 stunclk=160;
5201 2204 sfx(WAV_EHIT,pan(int32_t(x)));
5202
5203 2204 return 1;
5204 }
5205
5206 case edCHINKL1:
5207 if(*power >= 1*game->get_hero_dmgmult()) break;
5208 [[fallthrough]];
5209 case edCHINKL2:
5210
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(*power >= 2*game->get_hero_dmgmult()) break;
5211 [[fallthrough]];
5212 case edCHINKL4:
5213
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 19 times.
80 if(*power >= 4*game->get_hero_dmgmult()) break;
5214 [[fallthrough]];
5215 case edCHINKL6:
5216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 6*game->get_hero_dmgmult()) break;
5217 [[fallthrough]];
5218 case edCHINKL8:
5219
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 20 times.
35 if(*power >= 8*game->get_hero_dmgmult()) break;
5220 [[fallthrough]];
5221 case edCHINKL10:
5222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 10*game->get_hero_dmgmult()) break;
5223 [[fallthrough]];
5224 case edCHINK:
5225 //al_trace("defendNew() is at: %s\n", "returning edCHINK");
5226 199 sfx(WAV_CHINK,pan(int32_t(x)));
5227 199 return 1;
5228
5229 case edIGNOREL1:
5230 if(*power > 0) break;
5231 [[fallthrough]];
5232
5233 case edIGNORE:
5234 7801 return 0;
5235
5236 case ed1HKO:
5237 284 *power = hp;
5238 284 return -2;
5239
5240 case ed2x:
5241 {
5242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 *power = zc_max(1,*power*2);
5243 //int32_t pow = *power;
5244 //*power = vbound((pow*2),0,214747);
5245 71 return -1;
5246 }
5247 case ed3x:
5248 {
5249 *power = zc_max(1,*power*3);
5250 //int32_t pow = *power;
5251 //*power = vbound((pow*3),0,214747);
5252 return -1;
5253 }
5254
5255 case ed4x:
5256 {
5257 *power = zc_max(1,*power*4);
5258 //int32_t pow = *power;
5259 //*power = vbound((pow*4),0,214747);
5260 return -1;
5261 }
5262
5263
5264 case edHEAL:
5265 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
5266 //int32_t pow = *power;
5267 //*power = vbound((pow*-1),0,214747);
5268 //break;
5269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 *power = zc_min(0,*power*-1);
5270 79 return -1;
5271 }
5272 /*
5273 case edLEVELDAMAGE:
5274 {
5275 int32_t pow = *power;
5276 int32_t lvl = *level;
5277 *power = vbound((pow*lvl),0,214747);
5278 break;
5279 }
5280 case edLEVELREDUCTION:
5281 {
5282 int32_t pow = *power;
5283 int32_t lvl = *level;
5284 *power = vbound((pow/lvl),0,214747);
5285 break;
5286 }
5287 */
5288
5289 case edQUARTDAMAGE:
5290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 *power = zc_max(1,*power/2);
5291
5292 [[fallthrough]];
5293 case edHALFDAMAGE:
5294
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 192 times.
193 *power = zc_max(1,*power/2);
5295 193 break;
5296
5297 case edSWITCH:
5298 {
5299 if(Hero.switchhookclk) return 0; //Already switching!
5300 switch(family)
5301 {
5302 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
5303 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
5304 return 0;
5305 }
5306 hooked_combopos = -1;
5307 hooked_layerbits = 0;
5308 switching_object = this;
5309 switch_hooked = true;
5310 Hero.doSwitchHook(game->get_switchhookstyle());
5311 if(QMisc.miscsfx[sfxSWITCHED])
5312 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
5313 return 1;
5314 }
5315
5316 case 0:
5317 {
5318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46976 times.
46976 if(edef == edefSwitchHook)
5319 return -1;
5320
6/6
✓ Branch 0 taken 11895 times.
✓ Branch 1 taken 35081 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 11866 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 13 times.
46976 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK) && *power == 0)
5321 {
5322 13 sfx(WAV_CHINK,pan(int32_t(x)));
5323 13 return 1;
5324 }
5325
5326 }
5327 46963 }
5328
5329 47253 return -1;
5330 63287 }
5331
5332 63287 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
5333 {
5334
1/2
✓ Branch 0 taken 63287 times.
✗ Branch 1 not taken.
63287 int wuid = w?w->getUID():0;
5335
1/2
✓ Branch 0 taken 63287 times.
✗ Branch 1 not taken.
63287 bool fakeweap = (w && !Lwpns.getByUID(wuid));
5336
5337
1/2
✓ Branch 0 taken 63287 times.
✗ Branch 1 not taken.
63287 if(fakeweap)
5338 Lwpns.add(w);
5339 63287 std::vector<int32_t> &ev = FFCore.eventData;
5340 63287 ev.clear();
5341 63287 ev.push_back(*power*10000);
5342 63287 ev.push_back(edef*10000);
5343 63287 ev.push_back(unblockable*10000);
5344 63287 ev.push_back(wpnId*10000);
5345 63287 ev.push_back(0);
5346 63287 ev.push_back(getUID());
5347 63287 ev.push_back(wuid);
5348
5349 63287 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
5350 63287 *power = ev[0]/10000;
5351 63287 edef = ev[1]/10000;
5352 63287 unblockable = byte(ev[2]/10000);
5353 63287 wpnId = ev[3] / 10000;
5354 63287 bool nullify = ev[4]!=0;
5355 63287 ev.clear();
5356 63287 int ret = 0;
5357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63287 times.
63287 if(!nullify)
5358 {
5359 63287 ret = defendNew(wpnId, power, edef, unblockable);
5360
2/2
✓ Branch 0 taken 16563 times.
✓ Branch 1 taken 46724 times.
63287 if(ret == -1)
5361 {
5362 46724 ev.push_back(*power*10000);
5363 46724 ev.push_back(edef*10000);
5364 46724 ev.push_back(unblockable*10000);
5365 46724 ev.push_back(wpnId*10000);
5366 46724 ev.push_back(0);
5367 46724 ev.push_back(getUID());
5368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46724 times.
46724 ev.push_back(w?w->getUID():0);
5369
5370 46724 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
5371 46724 *power = ev[0]/10000;
5372 46724 nullify = ev[4]!=0;
5373 46724 ev.clear();
5374 46724 }
5375 63287 }
5376
1/2
✓ Branch 0 taken 63287 times.
✗ Branch 1 not taken.
63287 if(fakeweap)
5377 Lwpns.remove(w);
5378
5379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63287 times.
63287 return nullify ? 0 : ret;
5380 }
5381
5382 47521 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
5383 {
5384
2/2
✓ Branch 0 taken 47298 times.
✓ Branch 1 taken 223 times.
47521 if(!realweap) realweap = w;
5385 47521 int32_t wid = getWeaponID(w);
5386
5387 47521 int32_t edef = resolveEnemyDefence(w);
5388
2/2
✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 46261 times.
47521 if(QHeader.zelda_version > 0x250)
5389 1260 return defendNewInt(wid, power, edef, w->unblockable, realweap);
5390
2/3
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 45309 times.
✗ Branch 2 not taken.
46261 switch(wid)
5391 {
5392 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
5393 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
5394 952 return defend(wpnId, power, edefSCRIPT);
5395
5396 case wWhistle:
5397 return -1;
5398
5399 default:
5400 45309 return defendNewInt(wid, power, edef, w->unblockable, realweap);
5401 }
5402 47521 }
5403
5404
5405 // Check defenses without actually acting on them.
5406 8100 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
5407 {
5408
4/10
✓ Branch 0 taken 5779 times.
✓ Branch 1 taken 2059 times.
✓ Branch 2 taken 254 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8100 switch(defense[edef])
5409 {
5410 case edSTUNONLY:
5411 8 return false;
5412 case edSTUNORCHINK:
5413 case edCHINK:
5414 5779 return unblockable&WPNUNB_BLOCK;
5415 case edSTUNORIGNORE:
5416 case edIGNORE:
5417 2059 return unblockable&WPNUNB_IGNR;
5418
5419 case edIGNOREL1:
5420 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
5421 case edCHINKL1:
5422 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
5423
5424 case edCHINKL2:
5425 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
5426
5427 case edCHINKL4:
5428 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
5429
5430 case edCHINKL6:
5431 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
5432
5433 case edCHINKL8:
5434 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
5435 }
5436
5437 254 return true;
5438 8100 }
5439
5440 // Do we do damage?
5441 // 0: takehit returns 0
5442 // 1: takehit returns 1
5443 // -1: do damage
5444 952 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
5445 {
5446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 952 times.
952 if(shieldCanBlock)
5447 {
5448 switch(defense[edef])
5449 {
5450 case edIGNORE:
5451 return 0;
5452 case edIGNOREL1:
5453 case edSTUNORIGNORE:
5454 if(*power <= 0)
5455 return 0;
5456 }
5457
5458 sfx(WAV_CHINK,pan(int32_t(x)));
5459 return 1;
5460 }
5461
5462
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 759 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
952 switch(defense[edef])
5463 {
5464 case edSTUNORCHINK:
5465 if(*power <= 0)
5466 {
5467 sfx(WAV_CHINK,pan(int32_t(x)));
5468 return 1;
5469 }
5470
5471 [[fallthrough]];
5472 case edSTUNORIGNORE:
5473 if(*power <= 0)
5474 return 0;
5475
5476 [[fallthrough]];
5477 case edSTUNONLY:
5478 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
5479 return 1;
5480
5481 stunclk=160;
5482 sfx(WAV_EHIT,pan(int32_t(x)));
5483 return 1;
5484
5485 case edFREEZE:
5486 frozenclock=-1;
5487 //sfx(WAV_FREEZE,pan(int32_t(x)));
5488 return 1;
5489
5490 case edCHINKL1:
5491 if(*power >= 1*game->get_hero_dmgmult()) break;
5492 [[fallthrough]];
5493 case edCHINKL2:
5494 if(*power >= 2*game->get_hero_dmgmult()) break;
5495 [[fallthrough]];
5496 case edCHINKL4:
5497 if(*power >= 4*game->get_hero_dmgmult()) break;
5498 [[fallthrough]];
5499 case edCHINKL6:
5500 if(*power >= 6*game->get_hero_dmgmult()) break;
5501 [[fallthrough]];
5502 case edCHINKL8:
5503 if(*power >= 8*game->get_hero_dmgmult()) break;
5504 [[fallthrough]];
5505 case edCHINKL10:
5506 if(*power >= 10*game->get_hero_dmgmult()) break;
5507 [[fallthrough]];
5508 case edCHINK:
5509 sfx(WAV_CHINK,pan(int32_t(x)));
5510 return 1;
5511 case edTRIGGERSECRETS:
5512 hidden_entrance(0, true, false, -4);
5513 break;
5514
5515 case edIGNOREL1:
5516 if(*power > 0) break;
5517 [[fallthrough]];
5518 case edIGNORE:
5519 759 return 0;
5520
5521 case ed1HKO:
5522 *power = hp;
5523 return -2;
5524
5525 case ed2x:
5526 {
5527 *power = zc_max(1,*power*2);
5528 //int32_t pow = *power;
5529 //*power = vbound((pow*2),0,214747);
5530 return -1;
5531 }
5532 case ed3x:
5533 {
5534 *power = zc_max(1,*power*3);
5535 //int32_t pow = *power;
5536 //*power = vbound((pow*3),0,214747);
5537 return -1;
5538 }
5539
5540 case ed4x:
5541 {
5542 *power = zc_max(1,*power*4);
5543 //int32_t pow = *power;
5544 //*power = vbound((pow*4),0,214747);
5545 return -1;
5546 }
5547
5548
5549 case edHEAL:
5550 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
5551 //int32_t pow = *power;
5552 //*power = vbound((pow*-1),0,214747);
5553 //break;
5554 *power = zc_min(0,*power*-1);
5555 return -1;
5556 }
5557 /*
5558 case edLEVELDAMAGE:
5559 {
5560 int32_t pow = *power;
5561 int32_t lvl = *level;
5562 *power = vbound((pow*lvl),0,214747);
5563 break;
5564 }
5565 case edLEVELREDUCTION:
5566 {
5567 int32_t pow = *power;
5568 int32_t lvl = *level;
5569 *power = vbound((pow/lvl),0,214747);
5570 break;
5571 }
5572 */
5573
5574
5575 case edQUARTDAMAGE:
5576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
5577
5578 [[fallthrough]];
5579 case edHALFDAMAGE:
5580
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 *power = zc_max(1,*power/2);
5581 7 break;
5582 }
5583
5584 193 return -1;
5585 952 }
5586
5587 // Defend against a particular item class.
5588 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
5589 {
5590 int32_t def=-1;
5591
5592 switch(wpnId)
5593 {
5594 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
5595 case wBrang:
5596 def = defend(wpnId, power, edefBRANG);
5597 break;
5598
5599 case wHookshot:
5600 def = defend(wpnId, power, edefHOOKSHOT);
5601 break;
5602
5603 // Anyway...
5604 case wBomb:
5605 def = defend(wpnId, power, edefBOMB);
5606 break;
5607
5608 case wSBomb:
5609 def = defend(wpnId, power, edefSBOMB);
5610 break;
5611
5612 case wArrow:
5613 def = defend(wpnId, power, edefARROW);
5614 break;
5615
5616 case wFire:
5617 def = defend(wpnId, power, edefFIRE);
5618 break;
5619
5620 case wWand:
5621 def = defend(wpnId, power, edefWAND);
5622 break;
5623
5624 case wMagic:
5625 def = defend(wpnId, power, edefMAGIC);
5626 break;
5627
5628 case wHammer:
5629 def = defend(wpnId, power, edefHAMMER);
5630 break;
5631
5632 case wSword:
5633 def = defend(wpnId, power, edefSWORD);
5634 break;
5635
5636 case wBeam:
5637 def = defend(wpnId, power, edefBEAM);
5638 break;
5639
5640 case wRefBeam:
5641 def = defend(wpnId, power, edefREFBEAM);
5642 break;
5643
5644 case wRefMagic:
5645 def = defend(wpnId, power, edefREFMAGIC);
5646 break;
5647
5648 case wRefFireball:
5649 def = defend(wpnId, power, edefREFBALL);
5650 break;
5651
5652 case wRefRock:
5653 def = defend(wpnId, power, edefREFROCK);
5654 break;
5655
5656 case wStomp:
5657 def = defend(wpnId, power, edefSTOMP);
5658 break;
5659
5660 case wCByrna:
5661 def = defend(wpnId, power, edefBYRNA);
5662 break;
5663
5664 case wScript1:
5665 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
5666 else def = defend(wpnId, power, edefSCRIPT);
5667 break;
5668
5669 case wScript2:
5670 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
5671 else def = defend(wpnId, power, edefSCRIPT);
5672 break;
5673
5674 case wScript3:
5675 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
5676 else def = defend(wpnId, power, edefSCRIPT);
5677 break;
5678
5679 case wScript4:
5680 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
5681 else def = defend(wpnId, power, edefSCRIPT);
5682 break;
5683
5684 case wScript5:
5685 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
5686 else def = defend(wpnId, power, edefSCRIPT);
5687 break;
5688
5689 case wScript6:
5690 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
5691 else def = defend(wpnId, power, edefSCRIPT);
5692 break;
5693
5694 case wScript7:
5695 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
5696 else def = defend(wpnId, power, edefSCRIPT);
5697 break;
5698
5699 case wScript8:
5700 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
5701 else def = defend(wpnId, power, edefSCRIPT);
5702 break;
5703
5704 case wScript9:
5705 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
5706 else def = defend(wpnId, power, edefSCRIPT);
5707 break;
5708
5709 case wScript10:
5710 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
5711 else def = defend(wpnId, power, edefSCRIPT);
5712 break;
5713
5714 case wWhistle:
5715 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
5716 else break;
5717 break;
5718
5719
5720 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
5721 //Probably best to do this from the qest file, loading the values of Script(generic) into each
5722 //of the ten if the quest version is lower than N.
5723 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
5724 //such as bool UseSeparatedScriptDefences. hah.
5725 default:
5726 //if(wpnId>=wScript1 && wpnId<=wScript10)
5727 // {
5728 // def = defend(wpnId, power, edefSCRIPT);
5729 // }
5730 // }
5731
5732 break;
5733 }
5734
5735 return def;
5736 }
5737
5738 // take damage or ignore it
5739 // -1: damage (if any) dealt
5740 // 1: blocked
5741 // 0: weapon passes through unhindered
5742 137424 int32_t enemy::takehit(weapon *w, weapon* realweap)
5743 {
5744
2/4
✓ Branch 0 taken 137424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 137424 times.
137424 if(fallclk||drownclk) return 0;
5745
2/2
✓ Branch 0 taken 30955 times.
✓ Branch 1 taken 106469 times.
137424 if(!realweap) realweap = w;
5746 137424 int32_t wpnId = w->id;
5747 137424 int32_t power = w->power;
5748 137424 int32_t wpnx = w->x;
5749 137424 int32_t wpny = w->y;
5750 137424 int32_t enemyHitWeapon = w->parentitem;
5751 int32_t wpnDir;
5752 137424 int32_t parent_item = w->parentitem;
5753
5754
1/2
✓ Branch 0 taken 137424 times.
✗ Branch 1 not taken.
137424 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
5755 {
5756 wpnId = w->useweapon;
5757 }
5758
5759 // If it's a boomerang that just bounced, use the opposite direction;
5760 // otherwise, it might bypass a shield. This probably won't handle
5761 // every case correctly, but it's better than having shields simply
5762 // not work against boomerangs.
5763
8/8
✓ Branch 0 taken 16336 times.
✓ Branch 1 taken 121088 times.
✓ Branch 2 taken 10147 times.
✓ Branch 3 taken 6189 times.
✓ Branch 4 taken 9759 times.
✓ Branch 5 taken 388 times.
✓ Branch 6 taken 2398 times.
✓ Branch 7 taken 7361 times.
137424 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
5764 7361 wpnDir = oppositeDir[w->dir];
5765 else
5766 130063 wpnDir = w->dir;
5767
5768
5/8
✓ Branch 0 taken 137424 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137424 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 137424 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1855 times.
✓ Branch 7 taken 137741 times.
137424 if(dying || clk<0 || hclk>0 || superman)
5769 1855 return 0;
5770
5771 //Prevent boomerang from writing to hitby[] for more than one frame.
5772 //This also prevents stunlock.
5773 //if ( stunclk > 0 ) return 0;
5774 //this needs a rule for boomerangs that cannot stunlock!
5775 //further, bouncing weapons should probably SFX_CHINK and bounce here.
5776 //sigh.
5777
5778 137741 int32_t ret = -1;
5779
5780 // This obscure quest rule...
5781
5/6
✓ Branch 0 taken 74238 times.
✓ Branch 1 taken 63503 times.
✓ Branch 2 taken 74110 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 74110 times.
137741 if(get_bit(quest_rules,qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
5782 {
5783 double _MSVC2022_tmp1, _MSVC2022_tmp2;
5784 128 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
5785 128 wpnDir=zc_oldrand()&3;
5786
5787
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 53 times.
128 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
5788 {
5789 53 wpnDir=down;
5790 53 }
5791
4/4
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 36 times.
75 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
5792 {
5793 36 wpnDir=right;
5794 36 }
5795
4/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 7 times.
39 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
5796 {
5797 7 wpnDir=up;
5798 7 }
5799 else
5800 {
5801 32 wpnDir=left;
5802 }
5803 128 }
5804
5805 137741 int32_t xdir = dir;
5806 137741 shieldCanBlock=false;
5807
5808 //if (family==eeFLOAT && flags&(inv_front|inv_back_inv_left|inv_right)) xdir=down;
5809
4/4
✓ Branch 0 taken 135955 times.
✓ Branch 1 taken 1786 times.
✓ Branch 2 taken 397 times.
✓ Branch 3 taken 135558 times.
138535 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
5810
10/10
✓ Branch 0 taken 11657 times.
✓ Branch 1 taken 11260 times.
✓ Branch 2 taken 15451 times.
✓ Branch 3 taken 131367 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 131311 times.
✓ Branch 6 taken 982 times.
✓ Branch 7 taken 130329 times.
✓ Branch 8 taken 794 times.
✓ Branch 9 taken 129535 times.
135955 || ((flags&inv_front && wpnDir==(xdir^down)) || (flags&inv_back && wpnDir==(xdir^up)) || (flags&inv_left && wpnDir==(xdir^left)) || (flags&inv_right && wpnDir==(xdir^right))))
5811 )
5812 // The hammer should already be dealt with by subclasses (Walker etc.)
5813 {
5814
9/9
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 239 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 3575 times.
✓ Branch 4 taken 251 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 642 times.
✓ Branch 8 taken 484 times.
28940 switch(wpnId)
5815 {
5816 // Weapons which shields protect against
5817 case wSword:
5818 case wWand:
5819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3575 times.
3575 if(Hero.getCharging()>0)
5820 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
5821
5822 [[fallthrough]];
5823 case wHookshot:
5824 case wHSHandle:
5825 case wBrang:
5826 3814 shieldCanBlock=true;
5827 4065 break;
5828
5829 case wBeam:
5830 case wRefBeam:
5831 // Mirror shielded enemies!
5832 #if 0
5833 if(false /*flags2&guy_mirror*/ && !get_bit(quest_rules,qr_SWORDMIRROR))
5834 {
5835 if(wpnId>wEnemyWeapons)
5836 return 0;
5837
5838 sfx(WAV_CHINK,pan(int32_t(x)));
5839 return 1;
5840 }
5841
5842 #endif
5843
5844 [[fallthrough]];
5845 case wRefRock:
5846 case wRefFireball:
5847 case wMagic:
5848 #if 0
5849 if(false /*flags2&guy_mirror*/ && (wpnId!=wRefRock || get_bit(quest_rules,qr_REFLECTROCKS)))
5850 {
5851 sfx(WAV_CHINK,pan(int32_t(x)));
5852 return 3;
5853 }
5854
5855 #endif
5856
5857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 265 times.
265 if(wpnId>wEnemyWeapons)
5858 return 0;
5859
5860 [[fallthrough]];
5861 default:
5862 907 shieldCanBlock=true;
5863 907 break;
5864
5865 // Bombs
5866 case wSBomb:
5867 case wBomb:
5868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!get_bit(quest_rules,qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
5869 else if (!get_bit(quest_rules,qr_BOMBSPIERCESHIELD))
5870 {
5871 sfx(WAV_CHINK,pan(int32_t(x)));
5872 return 0;
5873 }
5874 else break;
5875
5876 // Weapons which ignore shields
5877 case wWhistle:
5878 case wHammer:
5879 1 break;
5880
5881 // Weapons which shouldn't be removed by shields
5882 case wLitBomb:
5883 case wLitSBomb:
5884 case wWind:
5885 case wPhantom:
5886 case wSSparkle:
5887 case wBait:
5888 416 return 0;
5889
5890 [[fallthrough]];
5891 case wFire:
5892 #if 0
5893 if(false /*flags2&guy_mirror*/)
5894 {
5895 sfx(WAV_CHINK,pan(int32_t(x)));
5896 return 1;
5897 }
5898
5899 #endif
5900 ;
5901 484 }
5902 5206 }
5903
5904
7/8
✓ Branch 0 taken 63063 times.
✓ Branch 1 taken 46926 times.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8100 times.
✓ Branch 5 taken 16321 times.
✓ Branch 6 taken 397 times.
✓ Branch 7 taken 1513 times.
136527 switch(wpnId)
5905 {
5906 case wWhistle: //No longer completely ignore whistle weapons! -Z
5907 {
5908
5909
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
207 if ( ((itemsbuf[parent_item].flags & ITEM_FLAG2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
5910 {
5911 //al_trace("Whistle weapon in %s\n", "takehit flag == 0");
5912 207 return 0; break;
5913 }
5914 else
5915 {
5916 w->power = power = itemsbuf[parent_item].misc5;
5917
5918 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
5919
5920 if(def <= 0)
5921 {
5922 if ( def == -2 ) hp -= hp;
5923 else hp -= power;
5924 return def;
5925 }
5926 break;
5927 }
5928 break;
5929 }
5930
5931 case wPhantom:
5932 return 0;
5933
5934 case wLitBomb:
5935 case wLitSBomb:
5936 case wBait:
5937 case wWind:
5938 case wSSparkle:
5939 63063 return 0;
5940
5941 case wFSparkle:
5942
5943 // Only take sparkle damage if the sparkle's parent item is not
5944 // defended against.
5945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8100 times.
8100 if(enemyHitWeapon > -1)
5946 {
5947 8100 int32_t p = 0;
5948 8100 int32_t f = itemsbuf[enemyHitWeapon].family;
5949
5950
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8100 times.
8100 switch(f)
5951 {
5952 case itype_arrow:
5953 if(!candamage(p, edefARROW, w->unblockable)) return 0;
5954
5955 break;
5956
5957 case itype_cbyrna:
5958 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
5959
5960 break;
5961
5962 case itype_brang:
5963
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 7846 times.
8100 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
5964
5965 254 break;
5966
5967 default:
5968 return 0;
5969 }
5970 254 }
5971
5972 254 wpnId = wSword;
5973 254 power = game->get_hero_dmgmult()>>1;
5974 254 goto fsparkle;
5975 break;
5976
5977 case wBrang:
5978 {
5979 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
5980 16321 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
5981 //preventing stunlock might be best, here. -Z
5982
2/2
✓ Branch 0 taken 3906 times.
✓ Branch 1 taken 12415 times.
16321 if(def >= 0) return def;
5983
5984 // Not hurt by 0-damage weapons
5985
2/2
✓ Branch 0 taken 2070 times.
✓ Branch 1 taken 10345 times.
12415 if(!(flags & guy_bhit))
5986 {
5987 10345 stunclk=160;
5988
5989
3/4
✓ Branch 0 taken 10345 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1153 times.
✓ Branch 3 taken 9192 times.
10345 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
5990 {
5991
1/2
✓ Branch 0 taken 1153 times.
✗ Branch 1 not taken.
1153 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
5992 1153 goto hitclock;
5993 }
5994
5995 9192 break;
5996 }
5997
5998
2/2
✓ Branch 0 taken 368 times.
✓ Branch 1 taken 1702 times.
2070 if(!power)
5999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1702 times.
1702 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
6000 else
6001 368 hp-=power;
6002
6003 2070 goto hitclock;
6004 }
6005
6006 case wHookshot:
6007 {
6008 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
6009 397 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
6010
6011
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 212 times.
397 if(def >= 0) return def;
6012
6013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 212 times.
212 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
6014
3/4
✓ Branch 0 taken 212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 6 times.
212 if(swgrab || !(flags & guy_bhit))
6015 {
6016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(!swgrab)
6017 206 stunclk=160;
6018
6019
2/4
✓ Branch 0 taken 206 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 206 times.
206 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
6020 {
6021 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
6022 goto hitclock;
6023 }
6024
6025 206 break;
6026 }
6027
6028
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
6 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
6029 else
6030 hp-=power;
6031
6032 6 goto hitclock;
6033 }
6034 break;
6035
6036 case wHSHandle:
6037 {
6038
3/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 1434 times.
1513 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & ITEM_FLAG1)
6039 79 return 0;
6040
6041
3/4
✓ Branch 0 taken 1053 times.
✓ Branch 1 taken 381 times.
✓ Branch 2 taken 381 times.
✗ Branch 3 not taken.
1434 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
6042
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
6043
6044 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
6045
6/8
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 992 times.
✓ Branch 2 taken 442 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 442 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 360 times.
1741 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
6046
6/6
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 496 times.
✓ Branch 2 taken 307 times.
✓ Branch 3 taken 631 times.
✓ Branch 4 taken 307 times.
✓ Branch 5 taken 324 times.
442 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(inv_back|inv_front|inv_left|inv_right))))
6047 324 return 0;
6048
6049 2102 power = game->get_hero_dmgmult();
6050 2356 }
6051
6052 fsparkle:
6053
6054 [[fallthrough]];
6055 default:
6056 // Work out the defenses!
6057 {
6058 47298 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
6059
6060
2/2
✓ Branch 0 taken 12829 times.
✓ Branch 1 taken 34469 times.
47298 if(def >= 0)
6061 12829 return def;
6062
2/2
✓ Branch 0 taken 34217 times.
✓ Branch 1 taken 252 times.
34469 else if(def == -2)
6063 {
6064 252 ret = 0;
6065 252 }
6066 }
6067
6068
2/2
✓ Branch 0 taken 34467 times.
✓ Branch 1 taken 2 times.
68938 if(!power)
6069 {
6070
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
6071 2 hp-=1;
6072 else
6073 {
6074 // Don't make a long chain of 'stun' hits
6075 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
6076 return 1;
6077
6078
6079 if(!switch_hooked)
6080 stunclk=160;
6081 break;
6082 }
6083 2 }
6084 34467 else hp-=power;
6085
6086 hitclock:
6087 37702 hclk=33;
6088
6089 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
6090
2/2
✓ Branch 0 taken 17596 times.
✓ Branch 1 taken 20106 times.
37702 if((dir&2)==(w->dir&2))
6091 {
6092 20106 sclk=(w->dir<<8)+16;
6093 20106 }
6094 37702 }
6095
6096
5/6
✓ Branch 0 taken 34685 times.
✓ Branch 1 taken 12415 times.
✓ Branch 2 taken 4455 times.
✓ Branch 3 taken 42645 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4455 times.
47100 if(((wpnId==wBrang) || (get_bit(quest_rules,qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
6097 {
6098 4455 fading=fade_blue_poof;
6099 4455 }
6100
6101
6/6
✓ Branch 0 taken 46094 times.
✓ Branch 1 taken 1006 times.
✓ Branch 2 taken 34206 times.
✓ Branch 3 taken 11888 times.
✓ Branch 4 taken 1328 times.
✓ Branch 5 taken 32878 times.
47100 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
6102 {
6103
1/2
✓ Branch 0 taken 2334 times.
✗ Branch 1 not taken.
2334 if( hitsfx > 0 ) //user-set hit sound.
6104 {
6105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2334 times.
2334 if (!dying) //don't play the hit sound on death! -Z
6106 2334 sfx(hitsfx, pan(int32_t(x)));
6107 2334 }
6108 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
6109 2334 }
6110 else //2.50.2 or earlier
6111 {
6112 44766 sfx(WAV_EHIT, pan(int32_t(x)));
6113 44766 sfx(hitsfx, pan(int32_t(x)));
6114 }
6115
2/2
✓ Branch 0 taken 47097 times.
✓ Branch 1 taken 3 times.
47100 if(family==eeGUY)
6116 3 sfx(WAV_EDEAD, pan(int32_t(x)));
6117
6118 // Penetrating weapons
6119
4/4
✓ Branch 0 taken 46476 times.
✓ Branch 1 taken 624 times.
✓ Branch 2 taken 41549 times.
✓ Branch 3 taken 5551 times.
47100 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
6120 {
6121 5551 int32_t item=enemyHitWeapon;
6122
6123
2/2
✓ Branch 0 taken 484 times.
✓ Branch 1 taken 5067 times.
5551 if(wpnId==wArrow)
6124 {
6125 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
6126
5/6
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 350 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 66 times.
484 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG1) && (itemsbuf[parent_item].family == itype_arrow))
6127 66 return 0;
6128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 418 times.
418 else if(get_bit(quest_rules,qr_ARROWS_ALWAYS_PENETRATE)) return 0;
6129 //if(item<0)
6130 else
6131 418 item=current_item_id(itype_arrow);
6132 418 }
6133
6134 else
6135 {
6136
6137 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
6138
2/6
✓ Branch 0 taken 5067 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5067 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5067 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG3) && (itemsbuf[parent_item].family == itype_sword))
6139 return 0;
6140
6141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5067 times.
5067 else if(get_bit(quest_rules,qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
6142 else
6143 //if(item<0)
6144 5067 item=current_item_id(itype_sword);
6145 }
6146 5485 }
6147
6148 47034 return ret;
6149 137810 }
6150
6151 24480783 bool enemy::dont_draw()
6152 {
6153
6/6
✓ Branch 0 taken 24380014 times.
✓ Branch 1 taken 100769 times.
✓ Branch 2 taken 24309107 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 30972 times.
✓ Branch 5 taken 24349042 times.
24480783 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
6154 131741 return true;
6155
6156
2/2
✓ Branch 0 taken 225193 times.
✓ Branch 1 taken 24123849 times.
24349042 if(flags&guy_invisible)
6157 225193 return true;
6158
6159
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 24123417 times.
✓ Branch 2 taken 432 times.
✗ Branch 3 not taken.
24123849 if(flags&lens_only && !lensclk)
6160 return true;
6161
6162
3/8
✓ Branch 0 taken 45951 times.
✓ Branch 1 taken 24077898 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45951 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
24123849 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) &&
6163 !((flags&lens_only) && (get_bit(quest_rules,qr_LENSSEESENEMIES) || (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5))))
6164 return true;
6165
6166 24123849 return false;
6167 24480783 }
6168
6169 #define DRAW_NORMAL 2
6170 #define DRAW_CLOAKED 1
6171 #define DRAW_INVIS 0
6172 // base drawing function to be used by all derived classes instead of
6173 // sprite::draw()
6174 21313720 void enemy::draw(BITMAP *dest)
6175 {
6176
6/6
✓ Branch 0 taken 21006153 times.
✓ Branch 1 taken 307567 times.
✓ Branch 2 taken 20923503 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 144417 times.
✓ Branch 5 taken 20861736 times.
21313720 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
6177 451984 return;
6178
2/2
✓ Branch 0 taken 1510281 times.
✓ Branch 1 taken 19351455 times.
20861736 if(flags&guy_invisible)
6179 1510281 return;
6180
3/8
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 19325197 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26258 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
19351455 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) && !(flags&lens_only))
6181 return;
6182
6183 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
6184 // be cloaked if they have "invisible displays as cloaked" checked.
6185
6186 19351455 byte canSee = DRAW_NORMAL;
6187 //Enemy specific stuff
6188
1/2
✓ Branch 0 taken 19351455 times.
✗ Branch 1 not taken.
19351455 if ( editorflags & ENEMY_FLAG1 )
6189 {
6190 canSee = DRAW_INVIS;
6191 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
6192 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
6193 {
6194 if (game->item[dmisc13])
6195 {
6196 canSee = DRAW_NORMAL;
6197 }
6198 //else if ( lensclk && getlensid.flags SHOWINVIS )
6199 //{
6200 //
6201 //}
6202 //else
6203 //{
6204 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
6205 // //otherwisem invisible
6206 //}
6207 }
6208 }
6209 //Room specific
6210
2/2
✓ Branch 0 taken 19162122 times.
✓ Branch 1 taken 189333 times.
19351455 if (tmpscr->flags3&fINVISROOM)
6211 {
6212
4/6
✓ Branch 0 taken 189333 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32460 times.
✓ Branch 3 taken 156873 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 32460 times.
221793 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
6213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32460 times.
32460 !((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
6214 189333 }
6215 //Lens check
6216
2/2
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 19325197 times.
19351455 if (lensclk)
6217 {
6218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26258 if((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(flags&lens_only))
6219 {
6220 if (canSee == DRAW_NORMAL)
6221 {
6222 if (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) canSee = DRAW_CLOAKED;
6223 else canSee = DRAW_INVIS; //Should never happen cause dont_draw should catch this, but just in case.
6224 }
6225 }
6226
2/2
✓ Branch 0 taken 25826 times.
✓ Branch 1 taken 432 times.
26258 if(flags&lens_only)
6227 {
6228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 432 times.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
6229 432 }
6230 26258 }
6231 else
6232 {
6233
2/2
✓ Branch 0 taken 19251781 times.
✓ Branch 1 taken 73416 times.
19325197 if(flags&lens_only)
6234 73416 canSee = DRAW_INVIS;
6235 }
6236
3/4
✓ Branch 0 taken 73416 times.
✓ Branch 1 taken 19278039 times.
✓ Branch 2 taken 73416 times.
✗ Branch 3 not taken.
19351455 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
6237
3/4
✓ Branch 0 taken 19245579 times.
✓ Branch 1 taken 105876 times.
✓ Branch 2 taken 19245579 times.
✗ Branch 3 not taken.
19351455 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
6238
6239
2/2
✓ Branch 0 taken 19278039 times.
✓ Branch 1 taken 73416 times.
19351455 if (canSee == DRAW_INVIS)
6240 73416 return;
6241
6242
3/4
✓ Branch 0 taken 19277897 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19277897 times.
19278039 if(fallclk||drownclk)
6243 {
6244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if (canSee == DRAW_CLOAKED)
6245 {
6246 sprite::drawcloaked(dest);
6247 }
6248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if (canSee == DRAW_NORMAL)
6249 {
6250 142 sprite::draw(dest);
6251 142 }
6252 142 return;
6253 }
6254 19277897 int32_t cshold=cs;
6255
6256
2/2
✓ Branch 0 taken 442088 times.
✓ Branch 1 taken 18835809 times.
19277897 if(dying)
6257 {
6258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 442088 times.
442088 if(clk2>=19)
6259 {
6260 if(!(clk2&2))
6261 {
6262 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
6263 if (canSee == DRAW_CLOAKED)
6264 {
6265 sprite::drawcloaked(dest);
6266 }
6267 else if (canSee == DRAW_NORMAL)
6268 {
6269 sprite::draw(dest);
6270 }
6271 }
6272 return;
6273 }
6274
6275 442088 flip = 0;
6276 442088 tile = wpnsbuf[spr_death].tile;
6277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 442088 times.
442088 if ( do_animation )
6278 {
6279 442088 int32_t offs = 0;
6280
2/2
✓ Branch 0 taken 437281 times.
✓ Branch 1 taken 4807 times.
442088 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
6281 {
6282
2/2
✓ Branch 0 taken 4568 times.
✓ Branch 1 taken 239 times.
4807 if(clk2 > 2)
6283 {
6284 239 spr_death_anim_clk=0;
6285 239 clk2=1;
6286
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 235 times.
239 if(hp > -1000)
6287 235 death_sfx();
6288 239 }
6289
4/4
✓ Branch 0 taken 4472 times.
✓ Branch 1 taken 335 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4456 times.
4807 if(clk2==1 && spr_death_anim_clk>-1)
6290 {
6291 4456 ++clk2;
6292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4456 times.
4456 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
6293
1/2
✓ Branch 0 taken 4456 times.
✗ Branch 1 not taken.
4456 spr_death_anim_frm *= zc_max(1,txsz);
6294 4456 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
6295
2/2
✓ Branch 0 taken 4383 times.
✓ Branch 1 taken 73 times.
4456 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
6296
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4456 times.
✓ Branch 2 taken 4456 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239 times.
✓ Branch 5 taken 4217 times.
4456 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
6297 {
6298 239 spr_death_anim_clk=-1;
6299 239 clk2=1;
6300 239 }
6301 4456 }
6302 4807 tile += spr_death_anim_frm;
6303 4807 }
6304
2/2
✓ Branch 0 taken 11115 times.
✓ Branch 1 taken 426166 times.
437281 else if(BSZ)
6305 {
6306
2/2
✓ Branch 0 taken 8742 times.
✓ Branch 1 taken 2373 times.
11115 offs = zc_min((15-clk2)/3,4);
6307 11115 }
6308
4/4
✓ Branch 0 taken 284151 times.
✓ Branch 1 taken 142015 times.
✓ Branch 2 taken 141912 times.
✓ Branch 3 taken 142239 times.
426166 else if(clk2>6 && clk2<=12)
6309 {
6310 142239 offs = 1;
6311 142239 }
6312
6313
2/2
✓ Branch 0 taken 290324 times.
✓ Branch 1 taken 151764 times.
442088 if(offs)
6314 {
6315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151764 times.
151764 offs *= zc_max(1,txsz);
6316 151764 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
6317
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 151716 times.
151764 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
6318 151764 }
6319 442088 tile += offs;
6320 442088 }
6321
6322
6/6
✓ Branch 0 taken 437281 times.
✓ Branch 1 taken 4807 times.
✓ Branch 2 taken 426166 times.
✓ Branch 3 taken 11115 times.
✓ Branch 4 taken 108169 times.
✓ Branch 5 taken 317997 times.
442088 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
6323 124091 cs = wpnsbuf[spr_death].csets&15;
6324 else
6325 317997 cs = (((clk2+5)>>1)&3)+6;
6326 442088 }
6327
3/4
✓ Branch 0 taken 598199 times.
✓ Branch 1 taken 18237610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 598199 times.
18835809 else if(hclk>0 && getCanFlicker())
6328 {
6329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 598199 times.
598199 if(family==eeGANON)
6330 cs=(((hclk-1)>>1)&3)+6;
6331
4/4
✓ Branch 0 taken 553689 times.
✓ Branch 1 taken 44510 times.
✓ Branch 2 taken 174114 times.
✓ Branch 3 taken 379575 times.
598199 else if(hclk<33 && !get_bit(quest_rules,qr_ENEMIESFLICKER))
6332 379575 cs=(((hclk-1)>>1)&3)+6;
6333 598199 }
6334 //draw every other frame for flickering enemies
6335
8/10
✓ Branch 0 taken 9631159 times.
✓ Branch 1 taken 9646738 times.
✓ Branch 2 taken 9631159 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 513540 times.
✓ Branch 5 taken 9117619 times.
✓ Branch 6 taken 137054 times.
✓ Branch 7 taken 376486 times.
✓ Branch 8 taken 137054 times.
✗ Branch 9 not taken.
19277897 if((frame&1)==1 || !(family !=eeGANON && hclk>0 && get_bit(quest_rules,qr_ENEMIESFLICKER) && getCanFlicker()))
6336 {
6337
2/2
✓ Branch 0 taken 32289 times.
✓ Branch 1 taken 19108554 times.
19140843 if (canSee == DRAW_CLOAKED)
6338 {
6339 32289 sprite::drawcloaked(dest);
6340 32289 }
6341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19108554 times.
19108554 else if (canSee == DRAW_NORMAL)
6342 {
6343
1/2
✓ Branch 0 taken 19108554 times.
✗ Branch 1 not taken.
19108554 if ( frozenclock < 0 )
6344 {
6345 if ( frozentile > 0 ) tile = frozentile;
6346 loadpalset(csBOSS,frozencset);
6347 }
6348 19108554 sprite::draw(dest);
6349 19108554 }
6350 19140843 }
6351 19277897 cs=cshold;
6352 21313720 }
6353
6354 //old zc bosses
6355 19770642 void enemy::drawzcboss(BITMAP *dest)
6356 {
6357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19770642 times.
19770642 if(dont_draw())
6358 return;
6359
6360 19770642 int32_t cshold=cs;
6361
6362
2/2
✓ Branch 0 taken 402772 times.
✓ Branch 1 taken 19367870 times.
19770642 if(dying)
6363 {
6364
2/2
✓ Branch 0 taken 2592 times.
✓ Branch 1 taken 400180 times.
402772 if(clk2>=19)
6365 {
6366
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 1296 times.
2592 if(!(clk2&2))
6367 1296 sprite::drawzcboss(dest);
6368
6369 2592 return;
6370 }
6371
6372 400180 flip = 0;
6373 400180 tile = wpnsbuf[spr_death].tile;
6374
6375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 400180 times.
400180 if ( do_animation )
6376 {
6377
2/2
✓ Branch 0 taken 397994 times.
✓ Branch 1 taken 2186 times.
400180 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
6378 {
6379
2/2
✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 2 times.
2186 if(clk2 > 2)
6380 {
6381 2 spr_death_anim_clk=0;
6382 2 clk2=1;
6383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(hp > -1000)
6384 2 death_sfx();
6385 2 }
6386
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 91 times.
✓ Branch 3 taken 2 times.
2186 if(clk2==1 && spr_death_anim_clk>-1)
6387 {
6388 2 ++clk2;
6389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
6390
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 spr_death_anim_frm *= zc_max(1,txsz);
6391 2 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
6392
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
6393
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
6394 {
6395 spr_death_anim_clk=-1;
6396 clk2=1;
6397 }
6398 2 }
6399 2186 tile += spr_death_anim_frm;
6400 2186 }
6401
2/2
✓ Branch 0 taken 11115 times.
✓ Branch 1 taken 386879 times.
397994 else if(BSZ)
6402
2/2
✓ Branch 0 taken 8742 times.
✓ Branch 1 taken 2373 times.
11115 tile += zc_min((15-clk2)/3,4);
6403
4/4
✓ Branch 0 taken 257845 times.
✓ Branch 1 taken 129034 times.
✓ Branch 2 taken 128785 times.
✓ Branch 3 taken 129060 times.
386879 else if(clk2>6 && clk2<=12)
6404 129060 ++tile;
6405 400180 }
6406
6407
6/6
✓ Branch 0 taken 397994 times.
✓ Branch 1 taken 2186 times.
✓ Branch 2 taken 386879 times.
✓ Branch 3 taken 11115 times.
✓ Branch 4 taken 105019 times.
✓ Branch 5 taken 281860 times.
400180 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
6408 118320 cs = wpnsbuf[spr_death].csets&15;
6409 else
6410 281860 cs = (((clk2+5)>>1)&3)+6;
6411 400180 }
6412
2/2
✓ Branch 0 taken 18773684 times.
✓ Branch 1 taken 594186 times.
19367870 else if(hclk>0)
6413 {
6414
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 591918 times.
594186 if(family==eeGANON)
6415 2268 cs=(((hclk-1)>>1)&3)+6;
6416
4/4
✓ Branch 0 taken 552628 times.
✓ Branch 1 taken 39290 times.
✓ Branch 2 taken 110465 times.
✓ Branch 3 taken 442163 times.
591918 else if(hclk<33 && !get_bit(quest_rules,qr_ENEMIESFLICKER))
6417 442163 cs=(((hclk-1)>>1)&3)+6;
6418 594186 }
6419
6420
2/4
✓ Branch 0 taken 163340 times.
✓ Branch 1 taken 19604710 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
19768050 if((tmpscr->flags3&fINVISROOM) &&
6421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 163340 times.
163340 !(current_item(itype_amulet)) &&
6422 !(get_bit(quest_rules,qr_LENSSEESENEMIES) &&
6423 lensclk) && family!=eeGANON)
6424 {
6425 sprite::drawcloaked(dest);
6426 }
6427 else
6428 {
6429
6/6
✓ Branch 0 taken 19752054 times.
✓ Branch 1 taken 15996 times.
✓ Branch 2 taken 976064 times.
✓ Branch 3 taken 18775990 times.
✓ Branch 4 taken 816559 times.
✓ Branch 5 taken 159505 times.
19768050 if(family !=eeGANON && hclk>0 && get_bit(quest_rules,qr_ENEMIESFLICKER))
6430 {
6431
2/2
✓ Branch 0 taken 15820 times.
✓ Branch 1 taken 143685 times.
159505 if((frame&1)==1)
6432 143685 sprite::drawzcboss(dest);
6433 159505 }
6434 else
6435 19608545 sprite::drawzcboss(dest);
6436 }
6437
6438 19768050 cs=cshold;
6439 19770642 }
6440
6441
6442 // similar to the overblock function--can do up to a 32x32 sprite
6443 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
6444 125739 void enemy::drawblock(BITMAP *dest,int32_t mask)
6445 {
6446 125739 int32_t thold=tile;
6447 125739 int32_t t1=tile;
6448 125739 int32_t t2=tile+20;
6449 125739 int32_t t3=tile+1;
6450 125739 int32_t t4=tile+21;
6451
6452
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 125739 times.
125739 switch(mask)
6453 {
6454 case 1:
6455 enemy::drawzcboss(dest);
6456 break;
6457
6458 case 3:
6459 if(flip&2)
6460 zc_swap(t1,t2);
6461
6462 tile=t1;
6463 enemy::drawzcboss(dest);
6464 tile=t2;
6465 yofs+=16;
6466 enemy::drawzcboss(dest);
6467 yofs-=16;
6468 break;
6469
6470 case 5:
6471 t2=tile+1;
6472
6473 if(flip&1)
6474 zc_swap(t1,t2);
6475
6476 tile=t1;
6477 enemy::drawzcboss(dest);
6478 tile=t2;
6479 xofs+=16;
6480 enemy::drawzcboss(dest);
6481 xofs-=16;
6482 break;
6483
6484 case 15:
6485
2/2
✓ Branch 0 taken 119973 times.
✓ Branch 1 taken 5766 times.
125739 if(flip&1)
6486 {
6487 5766 zc_swap(t1,t3);
6488 5766 zc_swap(t2,t4);
6489 5766 }
6490
6491
1/2
✓ Branch 0 taken 125739 times.
✗ Branch 1 not taken.
125739 if(flip&2)
6492 {
6493 zc_swap(t1,t2);
6494 zc_swap(t3,t4);
6495 }
6496
6497 125739 tile=t1;
6498 125739 enemy::drawzcboss(dest);
6499 125739 tile=t2;
6500 125739 yofs+=16;
6501 125739 enemy::drawzcboss(dest);
6502 125739 yofs-=16;
6503 125739 tile=t3;
6504 125739 xofs+=16;
6505 125739 enemy::drawzcboss(dest);
6506 125739 tile=t4;
6507 125739 yofs+=16;
6508 125739 enemy::drawzcboss(dest);
6509 125739 xofs-=16;
6510 125739 yofs-=16;
6511 125739 break;
6512 }
6513
6514 125739 tile=thold;
6515 125739 }
6516
6517 4496383 void enemy::drawshadow(BITMAP *dest, bool translucent)
6518 {
6519
4/4
✓ Branch 0 taken 4139449 times.
✓ Branch 1 taken 356934 times.
✓ Branch 2 taken 406089 times.
✓ Branch 3 taken 3733360 times.
4496383 if(dont_draw() || isSideViewGravity())
6520 {
6521 763023 return;
6522 }
6523
6524
2/2
✓ Branch 0 taken 63093 times.
✓ Branch 1 taken 3670267 times.
3733360 if(dying)
6525 {
6526 63093 return;
6527 }
6528
6529
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3670267 times.
✓ Branch 2 taken 145552 times.
✓ Branch 3 taken 3524715 times.
3670267 if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
6530 3670267 (darkroom))
6531 {
6532 145552 return;
6533 }
6534 else
6535 {
6536
4/4
✓ Branch 0 taken 3387103 times.
✓ Branch 1 taken 137612 times.
✓ Branch 2 taken 3378060 times.
✓ Branch 3 taken 9043 times.
3524715 if(enemycanfall(id, false) && shadowtile == 0)
6537 9043 shadowtile = wpnsbuf[spr_shadow].tile;
6538
6539
5/6
✓ Branch 0 taken 2952665 times.
✓ Branch 1 taken 572050 times.
✓ Branch 2 taken 2952665 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2815053 times.
✓ Branch 5 taken 137612 times.
3524715 if(z>0 || fakez>0 || !enemycanfall(id, false))
6540 {
6541
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 709546 times.
709662 if(!shadow_overpit(this))
6542 709546 sprite::drawshadow(dest,translucent);
6543 709662 }
6544 }
6545 4496383 }
6546
6547 79398 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
6548 {
6549 79398 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
6550
6551
1/2
✓ Branch 0 taken 79398 times.
✗ Branch 1 not taken.
79398 if(sub!=NULL)
6552 {
6553 79398 xofs-=mx;
6554 79398 yofs-=my;
6555 79398 enemy::draw(sub);
6556 79398 xofs+=mx;
6557 79398 yofs+=my;
6558 79398 destroy_bitmap(sub);
6559 79398 }
6560 else
6561 enemy::draw(dest);
6562 79398 }
6563
6564 // override hit detection to check for invicibility, stunned, etc
6565 52704 bool enemy::hit(sprite *s)
6566 {
6567
3/6
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52704 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 52704 times.
52704 if(!(s->scriptcoldet&1) || s->fallclk || s->drownclk) return false;
6568
6569
2/4
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52704 times.
✗ Branch 3 not taken.
52704 return (dying || hclk>0) ? false : sprite::hit(s);
6570 52704 }
6571
6572 23719939 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
6573 {
6574
4/4
✓ Branch 0 taken 23306230 times.
✓ Branch 1 taken 413709 times.
✓ Branch 2 taken 22646513 times.
✓ Branch 3 taken 659717 times.
23719939 return (dying || hclk>0) ? false : sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
6575 }
6576 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
6577 {
6578 return (dying || hclk>0) ? false : sprite::hit(tx,ty,txsz2,tysz2);
6579 }
6580
6581 6336689 bool enemy::hit(weapon *w)
6582 {
6583
4/6
✓ Branch 0 taken 6239434 times.
✓ Branch 1 taken 97255 times.
✓ Branch 2 taken 6239434 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6239434 times.
6336689 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk) return false;
6584
6585
4/4
✓ Branch 0 taken 6055515 times.
✓ Branch 1 taken 183919 times.
✓ Branch 2 taken 5759609 times.
✓ Branch 3 taken 295906 times.
6239434 return (dying || hclk>0) ? false : sprite::hit(w);
6586 6336689 }
6587
6588 5469433 bool enemy::can_pitfall(bool checkspawning)
6589 {
6590
4/4
✓ Branch 0 taken 5462868 times.
✓ Branch 1 taken 6565 times.
✓ Branch 2 taken 5461032 times.
✓ Branch 3 taken 8401 times.
5469433 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
6591
2/2
✓ Branch 0 taken 5454971 times.
✓ Branch 1 taken 6061 times.
5461032 switch(guysbuf[id&0xFFF].family)
6592 {
6593 case eeAQUA:
6594 case eeDIG:
6595 case eeDONGO:
6596 case eeFAIRY:
6597 case eeGANON:
6598 case eeGHOMA:
6599 case eeGLEEOK:
6600 case eeGUY:
6601 case eeLANM:
6602 case eeMANHAN:
6603 case eeMOLD:
6604 case eeNONE:
6605 case eePATRA:
6606 case eeZORA:
6607 6061 return false; //Disallowed types
6608 default:
6609 5454971 return true;
6610 }
6611 5469433 }
6612 //Handle death
6613 17937711 void enemy::try_death(bool force_kill)
6614 {
6615
8/8
✓ Branch 0 taken 17930748 times.
✓ Branch 1 taken 6963 times.
✓ Branch 2 taken 17930746 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 19475 times.
✓ Branch 5 taken 17911271 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 19474 times.
17937711 if(!dying && (force_kill || (hp<=0 && !immortal)))
6616 {
6617 19476 std::vector<int32_t> &ev = FFCore.eventData;
6618 19476 ev.clear();
6619 19476 ev.push_back(10000);
6620 19476 ev.push_back(getUID());
6621
6622 19476 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
6623 19476 bool isSaved = !ev[0];
6624 19476 ev.clear();
6625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19476 times.
19476 if(isSaved) return;
6626
6627
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 19457 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 17 times.
19476 if(itemguy && (hasitem&2)!=0)
6628 {
6629
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 17 times.
37 for(int32_t i=0; i<items.Count(); i++)
6630 {
6631
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 17 times.
20 if(((item*)items.spr(i))->pickup&ipENEMY)
6632 {
6633
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if (!get_bit(quest_rules, qr_BROKEN_ITEM_CARRYING))
6634 {
6635 if (get_bit(quest_rules, qr_ENEMY_DROPS_USE_HITOFFSETS))
6636 {
6637 items.spr(i)->x = x+hxofs+(hxsz/2)-8;
6638 items.spr(i)->y = y+hyofs+(hysz/2)-10-fakez;
6639 }
6640 else
6641 {
6642 if(extend >= 3)
6643 {
6644 items.spr(i)->x = x+(txsz-1)*8;
6645 items.spr(i)->y = y-2+(tysz-1)*8;
6646 }
6647 else
6648 {
6649 items.spr(i)->x = x;
6650 items.spr(i)->y = y - 2;
6651 }
6652 }
6653 items.spr(i)->z = z;
6654 items.spr(i)->fakez = fakez;
6655 }
6656 else
6657 {
6658 17 items.spr(i)->x = x;
6659 17 items.spr(i)->y = y - 2;
6660 }
6661 17 }
6662 20 }
6663 17 }
6664
6665 19476 dying=true;
6666
6667
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 19454 times.
19476 if(fading==fade_flash_die)
6668 22 clk2=19+18*4;
6669 else
6670 {
6671 19454 clk2 = BSZ ? 15 : 19;
6672
6673
2/2
✓ Branch 0 taken 4439 times.
✓ Branch 1 taken 15015 times.
19454 if(fading!=fade_blue_poof)
6674 15015 fading=0;
6675 }
6676
6677
2/2
✓ Branch 0 taken 19457 times.
✓ Branch 1 taken 19 times.
19476 if(itemguy)
6678 {
6679 19 hasitem&=~2;
6680 19 item_set=0;
6681 19 }
6682
6683
6/6
✓ Branch 0 taken 18792 times.
✓ Branch 1 taken 684 times.
✓ Branch 2 taken 14685 times.
✓ Branch 3 taken 4107 times.
✓ Branch 4 taken 48 times.
✓ Branch 5 taken 14637 times.
19476 if(currscr<128 && count_enemy && !script_spawned)
6684 14637 game->guys[(currmap<<7)+currscr]-=1;
6685 19476 }
6686 17937711 }
6687
6688 // --==**==--
6689
6690 // Movement routines that can be used by derived classes as needed
6691
6692 // --==**==--
6693
6694 277988 void enemy::fix_coords(bool bound)
6695 {
6696
1/2
✓ Branch 0 taken 277988 times.
✗ Branch 1 not taken.
277988 if ((get_bit(quest_rules,qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
6697
1/2
✓ Branch 0 taken 277988 times.
✗ Branch 1 not taken.
277988 if(moveflags & FLAG_IGNORE_SCREENEDGE) bound = false;
6698
6699
6700
2/2
✓ Branch 0 taken 35593 times.
✓ Branch 1 taken 242395 times.
277988 if(bound)
6701 {
6702
1/2
✓ Branch 0 taken 242395 times.
✗ Branch 1 not taken.
242395 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
6703 {
6704
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 242395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
242395 x=vbound(x, 0, (( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256-((txsz-1)*16)) : 240));
6705
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 242395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
242395 y=vbound(y, 0,(( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176-((txsz-1)*16)) : 160));
6706 242395 }
6707 else
6708 {
6709 x=vbound(x, 0,240);
6710 y=vbound(y, 0,160);
6711 }
6712 242395 }
6713
6714
6/10
✓ Branch 0 taken 276974 times.
✓ Branch 1 taken 1014 times.
✓ Branch 2 taken 277988 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 277988 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 277988 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 277988 times.
277988 if(!OUTOFBOUNDS)
6715 {
6716 /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0));
6717
6718 if(isSideViewGravity())
6719 y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0));
6720 else
6721 y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0));
6722 */
6723 277988 do_fix(x, 16, true);
6724
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 276974 times.
277988 if(isSideViewGravity())
6725 1014 do_fix(y,8,true);
6726 276974 else do_fix(y,16,true);
6727 277988 }
6728 277988 }
6729 5780 bool enemy::cannotpenetrate()
6730 {
6731
4/4
✓ Branch 0 taken 5673 times.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 5654 times.
5780 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
6732 }
6733
6734 375 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6735 {
6736 bool ok;
6737 375 int32_t dx = 0, dy = 0;
6738 375 int32_t sv = 8;
6739
6740 //Why is this here??? Why is it needed???
6741 375 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
6742
6743
8/9
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 65 times.
✓ Branch 5 taken 56 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 53 times.
✗ Branch 8 not taken.
375 switch(ndir)
6744 {
6745 case 8:
6746 case up:
6747
3/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
43 if(canfall(id) && isSideViewGravity())
6748 return false;
6749
6750 43 dy = dy1-s;
6751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 special = (special==spw_clipbottomright)?spw_none:special;
6752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
6753 43 break;
6754
6755 case 12:
6756 case down:
6757
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
37 if(canfall(id) && isSideViewGravity())
6758 return false;
6759
6760 37 dy = dy2+s;
6761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
6762 37 break;
6763
6764 case 14:
6765 case left:
6766 30 dx = dx1-s;
6767 30 sv = ((isSideViewGravity())?7:8);
6768
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
30 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
6769
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 29 times.
30 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
6770 30 break;
6771
6772 case 10:
6773 case right:
6774 49 dx = dx2+s;
6775 49 sv = ((isSideViewGravity())?7:8);
6776
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 45 times.
49 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
6777 49 break;
6778
6779 case 9:
6780 case r_up:
6781 65 dx = dx2+s;
6782 65 dy = dy1-s;
6783
3/4
✓ Branch 0 taken 65 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 1 times.
129 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6785 65 break;
6786
6787 case 11:
6788 case r_down:
6789 56 dx = dx2+s;
6790 56 dx = dy2+s;
6791
2/4
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6793 56 break;
6794
6795 case 13:
6796 case l_down:
6797 42 dx = dx1-s;
6798 42 dy = dy2+s;
6799
3/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
82 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6801 42 break;
6802
6803 case 15:
6804 case l_up:
6805 53 dx = dx1-s;
6806 53 dy = dy1-s;
6807
2/4
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
106 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6809 53 break;
6810
6811 default:
6812 db=99;
6813 return true;
6814 }
6815
6816 375 return ok;
6817 375 }
6818
6819
6820
6821
6822 // returns true if next step is ok, false if there is something there
6823 3302093 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
6824 {
6825 3302093 bool ok = false; //initialise the var, son't just declare it
6826 3302093 int32_t dx = 0, dy = 0;
6827 3302093 int32_t sv = 8;
6828 3302093 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
6829 //Why is this here??? Why is it needed???
6830 3302093 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
6831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3302093 times.
3302093 int32_t usexoffs = (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
6832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3302093 times.
3302093 int32_t useyoffs = (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
6833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3302093 times.
3302093 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
6834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3302093 times.
3302093 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
6835 3302093 bool offgrid = OFFGRID_ENEMY;
6836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3302093 times.
3302093 if(!offgrid)
6837 {
6838 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
6839
1/2
✓ Branch 0 taken 3302093 times.
✗ Branch 1 not taken.
3302093 if(usehei<16)usehei=16;
6840
1/2
✓ Branch 0 taken 3302093 times.
✗ Branch 1 not taken.
3302093 if(usewid<16)usewid=16;
6841 3302093 }
6842
9/9
✓ Branch 0 taken 609913 times.
✓ Branch 1 taken 488533 times.
✓ Branch 2 taken 545129 times.
✓ Branch 3 taken 551883 times.
✓ Branch 4 taken 253094 times.
✓ Branch 5 taken 304497 times.
✓ Branch 6 taken 280447 times.
✓ Branch 7 taken 267627 times.
✓ Branch 8 taken 970 times.
3302093 switch(ndir) //need to check every 8 pixels between two points
6843 {
6844 case 8:
6845 case up:
6846 {
6847
4/4
✓ Branch 0 taken 95305 times.
✓ Branch 1 taken 514608 times.
✓ Branch 2 taken 94715 times.
✓ Branch 3 taken 590 times.
609913 if(enemycanfall(id) && isSideViewGravity())
6848 590 return false;
6849
6850 609323 dy = dy1-s;
6851
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 609320 times.
609323 special = (special==spw_clipbottomright)?spw_none:special;
6852 609323 tries = usewid/(offgrid ? 8 : 16);
6853 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
6854
2/2
✓ Branch 0 taken 525062 times.
✓ Branch 1 taken 609323 times.
1134385 for ( ; tries > 0; --tries )
6855 {
6856
2/2
✓ Branch 0 taken 82698 times.
✓ Branch 1 taken 526625 times.
609323 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
6857 609323 try_x += (offgrid ? 8 : 16);
6858
2/2
✓ Branch 0 taken 525062 times.
✓ Branch 1 taken 84261 times.
609323 if (!ok) break;
6859 525062 }
6860
2/2
✓ Branch 0 taken 525062 times.
✓ Branch 1 taken 84261 times.
609323 if(!ok) break;
6861
1/2
✓ Branch 0 taken 525062 times.
✗ Branch 1 not taken.
525062 if((usewid%16)>0) //Uneven width
6862 {
6863 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
6864 }
6865 525062 break;
6866 }
6867 case 12:
6868 case down:
6869 {
6870
4/4
✓ Branch 0 taken 106098 times.
✓ Branch 1 taken 382435 times.
✓ Branch 2 taken 105410 times.
✓ Branch 3 taken 688 times.
488533 if(enemycanfall(id) && isSideViewGravity())
6871 688 return false;
6872
6873 487845 dy = dy2+s;
6874 487845 tries = usewid/(offgrid ? 8 : 16);
6875 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
6876
2/2
✓ Branch 0 taken 399886 times.
✓ Branch 1 taken 487845 times.
887731 for ( ; tries > 0; --tries )
6877 {
6878
3/4
✓ Branch 0 taken 87786 times.
✓ Branch 1 taken 400059 times.
✓ Branch 2 taken 400059 times.
✗ Branch 3 not taken.
487845 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
6879 487845 try_x += (offgrid ? 8 : 16);
6880
2/2
✓ Branch 0 taken 399886 times.
✓ Branch 1 taken 87959 times.
487845 if (!ok) break;
6881 399886 }
6882
2/2
✓ Branch 0 taken 399886 times.
✓ Branch 1 taken 87959 times.
487845 if(!ok) break;
6883
1/2
✓ Branch 0 taken 399886 times.
✗ Branch 1 not taken.
399886 if((usewid%16)>0) //Uneven width
6884 {
6885 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
6886 }
6887 399886 break;
6888 }
6889 case 14:
6890 case left:
6891 {
6892 545129 dx = dx1-s;
6893 545129 sv = ((isSideViewGravity())?7:0);
6894
4/4
✓ Branch 0 taken 545123 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1159 times.
✓ Branch 3 taken 543964 times.
545129 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
6895 545129 tries = usehei/(offgrid ? 8 : 16);
6896 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
6897
2/2
✓ Branch 0 taken 463705 times.
✓ Branch 1 taken 545129 times.
1008834 for ( ; tries > 0; --tries )
6898 {
6899
2/2
✓ Branch 0 taken 80933 times.
✓ Branch 1 taken 464196 times.
545129 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
6900 545129 try_y += (offgrid ? 8 : 16);
6901
2/2
✓ Branch 0 taken 463705 times.
✓ Branch 1 taken 81424 times.
545129 if (!ok) break;
6902 463705 }
6903
2/2
✓ Branch 0 taken 463705 times.
✓ Branch 1 taken 81424 times.
545129 if(!ok) break;
6904
1/2
✓ Branch 0 taken 463705 times.
✗ Branch 1 not taken.
463705 if((usehei%16)>0) //Uneven height
6905 {
6906 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
6907 }
6908 463705 break;
6909 }
6910 case 10:
6911 case right:
6912 {
6913 551883 dx = dx2+s;
6914 551883 sv = ((isSideViewGravity())?7:0);
6915 551883 tries = usehei/(offgrid ? 8 : 16);
6916 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
6917
2/2
✓ Branch 0 taken 472748 times.
✓ Branch 1 taken 551883 times.
1024631 for ( ; tries > 0; --tries )
6918 {
6919
3/4
✓ Branch 0 taken 78641 times.
✓ Branch 1 taken 473242 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 473242 times.
551883 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
6920 551883 try_y += (offgrid ? 8 : 16);
6921
2/2
✓ Branch 0 taken 472748 times.
✓ Branch 1 taken 79135 times.
551883 if (!ok) break;
6922 472748 }
6923
2/2
✓ Branch 0 taken 472748 times.
✓ Branch 1 taken 79135 times.
551883 if(!ok) break;
6924
1/2
✓ Branch 0 taken 472748 times.
✗ Branch 1 not taken.
472748 if((usehei%16)>0) //Uneven height
6925 {
6926 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
6927 }
6928 472748 break;
6929 }
6930 case 9:
6931 case r_up:
6932 {
6933 253094 dx = dx2+s;
6934 253094 dy = dy1-s;
6935 253094 int32_t tries_x = usewid/(offgrid ? 8 : 16);
6936 253094 sv = ((isSideViewGravity())?7:0);
6937
2/2
✓ Branch 0 taken 244891 times.
✓ Branch 1 taken 253094 times.
497985 for ( ; tries_x > 0; --tries_x )
6938 {
6939 253094 int32_t tries_y = usehei/(offgrid ? 8 : 16);
6940 253094 try_y = 0;
6941
2/2
✓ Branch 0 taken 244891 times.
✓ Branch 1 taken 253094 times.
497985 for ( ; tries_y > 0; --tries_y )
6942 {
6943
4/4
✓ Branch 0 taken 249586 times.
✓ Branch 1 taken 3508 times.
✓ Branch 2 taken 246891 times.
✓ Branch 3 taken 2695 times.
499985 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
6944
2/2
✓ Branch 0 taken 1515 times.
✓ Branch 1 taken 245376 times.
246891 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
6945 253094 try_y += (offgrid ? 8 : 16);
6946
2/2
✓ Branch 0 taken 244891 times.
✓ Branch 1 taken 8203 times.
253094 if (!ok) break;
6947 244891 }
6948
2/2
✓ Branch 0 taken 244891 times.
✓ Branch 1 taken 8203 times.
253094 if (!ok) break;
6949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244891 times.
244891 if((usehei%16)>0) //Uneven height
6950 {
6951 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
6952 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
6953 }
6954 244891 try_x += (offgrid ? 8 : 16);
6955 244891 }
6956
2/2
✓ Branch 0 taken 244891 times.
✓ Branch 1 taken 8203 times.
253094 if(!ok) break;
6957
1/2
✓ Branch 0 taken 244891 times.
✗ Branch 1 not taken.
244891 if((usewid%16)>0) //Uneven width
6958 {
6959 int32_t tries_y = usehei/(offgrid ? 8 : 16);
6960 try_y = 0;
6961 for ( ; tries_y > 0; --tries_y )
6962 {
6963 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
6964 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
6965 try_y += (offgrid ? 8 : 16);
6966 if (!ok) break;
6967 }
6968 if (!ok) break;
6969 if((usehei%16)>0) //Uneven height
6970 {
6971 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
6972 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
6973 }
6974 }
6975 244891 break;
6976 }
6977 case 11:
6978 case r_down:
6979 {
6980 304497 dx = dx2+s;
6981 304497 dx = dy2+s;
6982 304497 int32_t tries_x = usewid/(offgrid ? 8 : 16);
6983 //sv = ((isSideViewGravity())?7:0);
6984
2/2
✓ Branch 0 taken 297727 times.
✓ Branch 1 taken 304497 times.
602224 for ( ; tries_x > 0; --tries_x )
6985 {
6986 304497 int32_t tries_y = usehei/(offgrid ? 8 : 16);
6987 304497 try_y = 0;
6988
2/2
✓ Branch 0 taken 297727 times.
✓ Branch 1 taken 304497 times.
602224 for ( ; tries_y > 0; --tries_y )
6989 {
6990
4/4
✓ Branch 0 taken 304366 times.
✓ Branch 1 taken 131 times.
✓ Branch 2 taken 297864 times.
✓ Branch 3 taken 6502 times.
602361 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
6991
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 297845 times.
297864 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
6992 304497 try_y += (offgrid ? 8 : 16);
6993
2/2
✓ Branch 0 taken 297727 times.
✓ Branch 1 taken 6770 times.
304497 if (!ok) break;
6994 297727 }
6995
2/2
✓ Branch 0 taken 297727 times.
✓ Branch 1 taken 6770 times.
304497 if (!ok) break;
6996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297727 times.
297727 if((usehei%16)>0) //Uneven height
6997 {
6998 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
6999 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
7000 }
7001 297727 try_x += (offgrid ? 8 : 16);
7002 297727 }
7003
2/2
✓ Branch 0 taken 297727 times.
✓ Branch 1 taken 6770 times.
304497 if(!ok) break;
7004
1/2
✓ Branch 0 taken 297727 times.
✗ Branch 1 not taken.
297727 if((usewid%16)>0) //Uneven width
7005 {
7006 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7007 try_y = 0;
7008 for ( ; tries_y > 0; --tries_y )
7009 {
7010 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
7011 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
7012 try_y += (offgrid ? 8 : 16);
7013 if (!ok) break;
7014 }
7015 if (!ok) break;
7016 if((usehei%16)>0) //Uneven height
7017 {
7018 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
7019 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
7020 }
7021 }
7022 297727 break;
7023 }
7024 case 13:
7025 case l_down:
7026 {
7027 280447 dx = dx1-s;
7028 280447 dy = dy2+s;
7029 280447 int32_t tries_x = usewid/(offgrid ? 8 : 16);
7030 //sv = ((isSideViewGravity())?7:0);
7031
2/2
✓ Branch 0 taken 273481 times.
✓ Branch 1 taken 280447 times.
553928 for ( ; tries_x > 0; --tries_x )
7032 {
7033 280447 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7034 280447 try_y = 0;
7035
2/2
✓ Branch 0 taken 273481 times.
✓ Branch 1 taken 280447 times.
553928 for ( ; tries_y > 0; --tries_y )
7036 {
7037
4/4
✓ Branch 0 taken 275752 times.
✓ Branch 1 taken 4695 times.
✓ Branch 2 taken 273617 times.
✓ Branch 3 taken 2135 times.
554064 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
7038
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 273504 times.
273617 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
7039 280447 try_y += (offgrid ? 8 : 16);
7040
2/2
✓ Branch 0 taken 273481 times.
✓ Branch 1 taken 6966 times.
280447 if (!ok) break;
7041 273481 }
7042
2/2
✓ Branch 0 taken 273481 times.
✓ Branch 1 taken 6966 times.
280447 if (!ok) break;
7043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 273481 times.
273481 if((usehei%16)>0) //Uneven height
7044 {
7045 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
7046 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
7047 }
7048 273481 try_x += (offgrid ? 8 : 16);
7049 273481 }
7050
2/2
✓ Branch 0 taken 273481 times.
✓ Branch 1 taken 6966 times.
280447 if(!ok) break;
7051
1/2
✓ Branch 0 taken 273481 times.
✗ Branch 1 not taken.
273481 if((usewid%16)>0) //Uneven width
7052 {
7053 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7054 try_y = 0;
7055 for ( ; tries_y > 0; --tries_y )
7056 {
7057 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
7058 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
7059 try_y += (offgrid ? 8 : 16);
7060 if (!ok) break;
7061 }
7062 if (!ok) break;
7063 if((usehei%16)>0) //Uneven height
7064 {
7065 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
7066 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
7067 }
7068 }
7069 273481 break;
7070 }
7071 case 15:
7072 case l_up:
7073 {
7074 267627 dx = dx1-s;
7075 267627 dy = dy1-s;
7076 267627 int32_t tries_x = usewid/(offgrid ? 8 : 16);
7077 267627 sv = ((isSideViewGravity())?7:0);
7078
2/2
✓ Branch 0 taken 259863 times.
✓ Branch 1 taken 267627 times.
527490 for ( ; tries_x > 0; --tries_x )
7079 {
7080 267627 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7081 267627 try_y = 0;
7082
2/2
✓ Branch 0 taken 259863 times.
✓ Branch 1 taken 267627 times.
527490 for ( ; tries_y > 0; --tries_y )
7083 {
7084
4/4
✓ Branch 0 taken 263936 times.
✓ Branch 1 taken 3691 times.
✓ Branch 2 taken 261941 times.
✓ Branch 3 taken 1995 times.
529568 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
7085
2/2
✓ Branch 0 taken 1587 times.
✓ Branch 1 taken 260354 times.
261941 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
7086 267627 try_y += (offgrid ? 8 : 16);
7087
2/2
✓ Branch 0 taken 259863 times.
✓ Branch 1 taken 7764 times.
267627 if (!ok) break;
7088 259863 }
7089
2/2
✓ Branch 0 taken 259863 times.
✓ Branch 1 taken 7764 times.
267627 if (!ok) break;
7090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259863 times.
259863 if((usehei%16)>0) //Uneven height
7091 {
7092 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
7093 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
7094 }
7095 259863 try_x += (offgrid ? 8 : 16);
7096 259863 }
7097
2/2
✓ Branch 0 taken 259863 times.
✓ Branch 1 taken 7764 times.
267627 if(!ok) break;
7098
1/2
✓ Branch 0 taken 259863 times.
✗ Branch 1 not taken.
259863 if((usewid%16)>0) //Uneven width
7099 {
7100 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7101 try_y = 0;
7102 for ( ; tries_y > 0; --tries_y )
7103 {
7104 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
7105 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
7106 try_y += (offgrid ? 8 : 16);
7107 if (!ok) break;
7108 }
7109 if (!ok) break;
7110 if((usehei%16)>0) //Uneven height
7111 {
7112 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
7113 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
7114 }
7115 }
7116 259863 break;
7117 }
7118 default:
7119 970 db=99;
7120 970 return true;
7121 }
7122 //Z_eventlog("\n");
7123 3299845 return ok;
7124 3302093 }
7125
7126
7127 2142317 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
7128 {
7129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2142317 times.
2142317 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
7130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2142317 times.
2142317 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
7131
1/2
✓ Branch 0 taken 2142317 times.
✗ Branch 1 not taken.
2142317 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
7132
1/2
✓ Branch 0 taken 2142317 times.
✗ Branch 1 not taken.
2142317 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
7133 2142317 --usewid;
7134 2142317 --usehei;
7135 2142317 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
7136 }
7137
7138 565123 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
7139 {
7140 565123 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
7141
7142
4/4
✓ Branch 0 taken 4383 times.
✓ Branch 1 taken 560740 times.
✓ Branch 2 taken 3266 times.
✓ Branch 3 taken 1117 times.
565123 if(special==spw_clipright&&ndir==right)
7143 {
7144 1117 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
7145 1117 }
7146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565123 times.
565123 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
7147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565123 times.
565123 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
7148
1/2
✓ Branch 0 taken 565123 times.
✗ Branch 1 not taken.
565123 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
7149
1/2
✓ Branch 0 taken 565123 times.
✗ Branch 1 not taken.
565123 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
7150 565123 --usewid;
7151 565123 --usehei;
7152
2/2
✓ Branch 0 taken 301972 times.
✓ Branch 1 taken 263151 times.
565123 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
7153 }
7154
7155 56082 bool enemy::canmove(int32_t ndir, bool kb)
7156 {
7157 56082 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
7158 }
7159
7160 // 8-directional
7161 375 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
7162 {
7163 375 int32_t ndir=0;
7164
7165 // can move straight, check if it wants to turn
7166
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 8 times.
375 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
7167 {
7168
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 367 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
367 if(grumble && (zc_oldrand()&4)<grumble) //Homing
7169 {
7170 int32_t w = Lwpns.idFirst(wBait);
7171
7172 if(w>=0)
7173 {
7174 int32_t bx = Lwpns.spr(w)->x;
7175 int32_t by = Lwpns.spr(w)->y;
7176
7177 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
7178
7179 if(abs(int32_t(y)-by)>14)
7180 {
7181 if(ndir>0) // Already left or right
7182 {
7183 // Making the diagonal directions
7184 ndir += (by<y) ? 2 : 4;
7185 }
7186 else
7187 {
7188 ndir = (by<y) ? up : down;
7189 }
7190 }
7191
7192 if(canmove(ndir,special,false))
7193 {
7194 dir=ndir;
7195 return;
7196 }
7197 }
7198 }
7199
7200 // Homing added.
7201
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 367 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
367 if(newhoming && (zc_oldrand()&255)<newhoming)
7202 {
7203 ndir = lined_up(8,true);
7204
7205 if(ndir>=0 && canmove(ndir,special,false))
7206 {
7207 dir=ndir;
7208 }
7209
7210 return;
7211 }
7212
7213 367 int32_t r=zc_oldrand();
7214
7215
2/4
✓ Branch 0 taken 367 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 367 times.
367 if(newrate>0 && !(r%newrate))
7216 {
7217 367 ndir = ((dir+((r&64)?-1:1))&7)+8;
7218 367 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
7219
7220
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 14 times.
367 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7221 353 dir=ndir;
7222
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
14 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
7223 11 dir=ndir2;
7224
7225
3/4
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 353 times.
✗ Branch 3 not taken.
367 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
7226 // due to numerous lost fractional components. -L
7227 {
7228 x.doFloor();
7229 y.doFloor();
7230 }
7231 367 }
7232
7233 367 return;
7234 }
7235
7236 // can't move straight, must turn
7237 8 int32_t i=0;
7238
7239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 for(; i<32; i++) // Try random dir
7240 {
7241 15 ndir=(zc_oldrand()&7)+8;
7242
7243
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
15 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7244 8 break;
7245 7 }
7246
7247
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(i==32)
7248 {
7249 for(ndir=8; ndir<16; ndir++)
7250 {
7251 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7252 goto ok;
7253 }
7254
7255 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
7256 }
7257
7258 ok:
7259 8 dir=ndir;
7260 8 x.doFloor();
7261 8 y.doFloor();
7262 375 }
7263
7264 269674 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
7265 {
7266 269674 int32_t ndir=0;
7267
7268 // can move straight, check if it wants to turn
7269
2/2
✓ Branch 0 taken 254132 times.
✓ Branch 1 taken 15542 times.
269674 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
7270 {
7271
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 254132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
254132 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
7272 {
7273 int32_t i = Lwpns.idFirst(wBait);
7274 if(i >= 0) //idfirst returns -1 if it can't find any
7275 {
7276 weapon *w = (weapon*)Lwpns.spr(i);
7277 if (get_bit(quest_rules, qr_FIND_CLOSEST_BAIT))
7278 {
7279 int32_t currentrange;
7280 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
7281 else currentrange = -1;
7282 int curid = i;
7283 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
7284 for(; i<Lwpns.Count(); ++i)
7285 {
7286 weapon *lw = (weapon*)Lwpns.spr(i);
7287 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
7288 {
7289 currentrange = distance(x, y, lw->x, lw->y);
7290 curid = i;
7291 }
7292 }
7293 i = curid;
7294 if (currentrange == -1) i = -1;
7295 }
7296 else
7297 {
7298 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
7299 }
7300 if(i>=0)
7301 {
7302 int32_t bx = Lwpns.spr(i)->x;
7303 int32_t by = Lwpns.spr(i)->y;
7304
7305 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
7306
7307 if(abs(int32_t(y)-by)>14)
7308 {
7309 if(ndir>0) // Already left or right
7310 {
7311 // Making the diagonal directions
7312 ndir += (by<y) ? 2 : 4;
7313 }
7314 else
7315 {
7316 ndir = (by<y) ? up : down;
7317 }
7318 }
7319 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
7320 if(canmove(ndir,special,false))
7321 {
7322 dir=ndir;
7323 return;
7324 }
7325 }
7326 }
7327 }
7328
7329 // Homing added.
7330
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 254132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
254132 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
7331 {
7332 ndir = lined_up(8,true);
7333 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
7334 if(ndir>=0 && canmove(ndir,special,false))
7335 {
7336 dir=ndir;
7337 }
7338
7339 return;
7340 }
7341
7342 254132 int32_t r=zc_oldrand();
7343
7344
4/4
✓ Branch 0 taken 164978 times.
✓ Branch 1 taken 89154 times.
✓ Branch 2 taken 88838 times.
✓ Branch 3 taken 76140 times.
254132 if(newrate>0 && !(r%newrate))
7345 {
7346 76140 ndir = ((dir+((r&64)?-1:1))&7)+8;
7347 76140 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
7348
7349
2/2
✓ Branch 0 taken 73642 times.
✓ Branch 1 taken 2498 times.
76140 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7350 73642 dir=ndir;
7351
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 2412 times.
2498 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
7352 2412 dir=ndir2;
7353
7354
4/4
✓ Branch 0 taken 73642 times.
✓ Branch 1 taken 2498 times.
✓ Branch 2 taken 70181 times.
✓ Branch 3 taken 3461 times.
76140 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
7355 // due to numerous lost fractional components. -L
7356 {
7357 3461 x.doFloor();
7358 3461 y.doFloor();
7359 3461 }
7360 76140 }
7361
7362 254132 return;
7363 }
7364
7365 // can't move straight, must turn
7366 15542 int32_t i=0;
7367
7368
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 28899 times.
28913 for(; i<32; i++) // Try random dir
7369 {
7370 28899 ndir=(zc_oldrand()&7)+8;
7371
7372
2/2
✓ Branch 0 taken 13371 times.
✓ Branch 1 taken 15528 times.
28899 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7373 15528 break;
7374 13371 }
7375
7376
2/2
✓ Branch 0 taken 15528 times.
✓ Branch 1 taken 14 times.
15546 if(i==32)
7377 {
7378
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 4 times.
48 for(ndir=8; ndir<16; ndir++)
7379 {
7380
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 10 times.
44 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7381 10 goto ok;
7382 34 }
7383
7384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
7385 4 }
7386
7387 ok:
7388 15542 dir=ndir;
7389 15542 x.doFloor();
7390 15542 y.doFloor();
7391 269674 }
7392
7393 266289 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
7394 {
7395 266289 newdir_8(newrate,newhoming,special,0,-8,15,15);
7396 266289 }
7397
7398 375 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
7399 {
7400 375 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
7401 375 }
7402
7403 // makes the enemy slide backwards when hit
7404 // sclk: first byte is clk, second byte is dir
7405 // makes the enemy slide backwards when hit
7406 // sclk: first byte is clk, second byte is dir
7407 7993087 int32_t enemy::slide()
7408 {
7409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7993087 times.
7993087 if(script_knockback_clk!=0) //scripted knockback
7410 {
7411 sclk = 0;
7412 return 1; //scripted knockback ran
7413 }
7414
5/6
✓ Branch 0 taken 49851 times.
✓ Branch 1 taken 7943236 times.
✓ Branch 2 taken 5314 times.
✓ Branch 3 taken 44537 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5314 times.
7993087 if(sclk==0 || (hp<=0 && !immortal))
7415 7948550 return 0;
7416
7417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44537 times.
44537 if(knockbackflags & FLAG_NOSLIDE)
7418 {
7419 sclk = 0;
7420 if(!OFFGRID_ENEMY)
7421 {
7422 //Fix to grid
7423 //x = (int32_t(x)+8)-((int32_t(x)+8)%16);
7424 //y = (int32_t(y)+8)-((int32_t(y)+8)%16);
7425 do_fix(x, 16, true);
7426 do_fix(y, 16, true);
7427 }
7428 return 0;
7429 }
7430
8/10
✓ Branch 0 taken 4518 times.
✓ Branch 1 taken 40019 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 4493 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
✓ Branch 6 taken 3345 times.
✓ Branch 7 taken 1148 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 25 times.
44537 if((sclk&255)==16 && (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
7431 {
7432 1148 sclk=0;
7433 1148 return 0;
7434 }
7435
7436 43389 --sclk;
7437
7438
5/5
✓ Branch 0 taken 1557 times.
✓ Branch 1 taken 5135 times.
✓ Branch 2 taken 5302 times.
✓ Branch 3 taken 14474 times.
✓ Branch 4 taken 16921 times.
43389 switch(sclk>>8)
7439 {
7440 case up:
7441 {
7442
4/4
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 4534 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 5129 times.
5135 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
7443 {
7444 6 sclk=0;
7445 6 return 0;
7446 }
7447
4/4
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 4528 times.
✓ Branch 2 taken 509 times.
✓ Branch 3 taken 92 times.
5129 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
7448
7449 5037 break;
7450 }
7451 case down:
7452 {
7453
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5300 times.
5302 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
7454 {
7455 2 sclk=0;
7456 2 return 0;
7457 }
7458
4/4
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 4596 times.
✓ Branch 2 taken 613 times.
✓ Branch 3 taken 91 times.
5300 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
7459
7460 5209 break;
7461 }
7462 case left:
7463 {
7464
4/4
✓ Branch 0 taken 1233 times.
✓ Branch 1 taken 13241 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 14461 times.
14474 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
7465 {
7466 13 sclk=0;
7467 13 return 0;
7468 }
7469
4/4
✓ Branch 0 taken 1233 times.
✓ Branch 1 taken 13228 times.
✓ Branch 2 taken 1132 times.
✓ Branch 3 taken 101 times.
14461 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
7470
7471 14360 break;
7472 }
7473 case right:
7474 {
7475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16921 times.
16921 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
7476 {
7477 sclk=0;
7478 return 0;
7479 }
7480
4/4
✓ Branch 0 taken 2217 times.
✓ Branch 1 taken 14704 times.
✓ Branch 2 taken 2067 times.
✓ Branch 3 taken 150 times.
16921 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
7481 16771 break;
7482 }
7483 }
7484
7485 42934 int32_t move = knockbackSpeed;
7486
2/2
✓ Branch 0 taken 40722 times.
✓ Branch 1 taken 42934 times.
83656 while(move>0)
7487 {
7488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42934 times.
42934 int32_t thismove = zc_min(8, move);
7489 42934 move -= thismove;
7490 42934 hitdir = (sclk>>8);
7491
5/5
✓ Branch 0 taken 1557 times.
✓ Branch 1 taken 5037 times.
✓ Branch 2 taken 5209 times.
✓ Branch 3 taken 14360 times.
✓ Branch 4 taken 16771 times.
42934 switch(sclk>>8)
7492 {
7493 case up:
7494 5037 y-=thismove;
7495 5037 break;
7496
7497 case down:
7498 5209 y+=thismove;
7499 5209 break;
7500
7501 case left:
7502 14360 x-=thismove;
7503 14360 break;
7504
7505 case right:
7506 16771 x+=thismove;
7507 16771 break;
7508 }
7509
2/2
✓ Branch 0 taken 40722 times.
✓ Branch 1 taken 2212 times.
42934 if(!canmove(sclk>>8,(zfix)0,0,true))
7510 {
7511
3/3
✓ Branch 0 taken 887 times.
✓ Branch 1 taken 1322 times.
✓ Branch 2 taken 3 times.
2212 switch(sclk>>8)
7512 {
7513 case up:
7514 case down:
7515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 887 times.
887 if(y < 0)
7516 y = 0;
7517
2/2
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 726 times.
887 else if((int32_t(y)&15) > 7)
7518 161 y=(int32_t(y)&0xF0)+16;
7519 else
7520 726 y=(int32_t(y)&0xF0);
7521
7522 887 break;
7523
7524 case left:
7525 case right:
7526
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1321 times.
1322 if(x < 0)
7527 1 x = 0;
7528
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 931 times.
1321 else if((int32_t(x)&15) > 7)
7529 390 x=(int32_t(x)&0xF0)+16;
7530 else
7531 931 x=(int32_t(x)&0xF0);
7532
7533 1322 break;
7534 }
7535
7536 2212 sclk=0;
7537 2212 clk3=0;
7538 2212 break;
7539 }
7540 }
7541
7542
2/2
✓ Branch 0 taken 39589 times.
✓ Branch 1 taken 3345 times.
42934 if((sclk&255)==0)
7543 {
7544 //hitdir = -1;
7545 3345 sclk=0;
7546 3345 }
7547 42934 return 2;
7548 7993087 }
7549
7550 bool enemy::can_slide()
7551 {
7552 if(sclk==0 || (hp<=0 && !immortal))
7553 return false;
7554
7555 if((sclk&255)==16 && (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
7556 {
7557 return false;
7558 }
7559
7560 return true;
7561 }
7562
7563 bool enemy::fslide()
7564 {
7565 if(sclk==0 || (hp<=0 && !immortal))
7566 return false;
7567
7568 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
7569 {
7570 sclk=0;
7571 return false;
7572 }
7573
7574 --sclk;
7575
7576 switch(sclk>>8)
7577 {
7578 case up:
7579 if(y<=16)
7580 {
7581 sclk=0;
7582 return false;
7583 }
7584
7585 break;
7586
7587 case down:
7588 if(y>=160)
7589 {
7590 sclk=0;
7591 return false;
7592 }
7593
7594 break;
7595
7596 case left:
7597 if(x<=16)
7598 {
7599 sclk=0;
7600 return false;
7601 }
7602
7603 break;
7604
7605 case right:
7606 if(x>=240)
7607 {
7608 sclk=0;
7609 return false;
7610 }
7611
7612 break;
7613 }
7614 hitdir = (sclk>>8);
7615 switch(sclk>>8)
7616 {
7617 case up:
7618 y-=4;
7619 break;
7620
7621 case down:
7622 y+=4;
7623 break;
7624
7625 case left:
7626 x-=4;
7627 break;
7628
7629 case right:
7630 x+=4;
7631 break;
7632 }
7633
7634 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
7635 {
7636 switch(sclk>>8)
7637 {
7638 case up:
7639 case down:
7640 if((int32_t(y)&15) > 7)
7641 y=(int32_t(y)&0xF0)+16;
7642 else
7643 y=(int32_t(y)&0xF0);
7644
7645 break;
7646
7647 case left:
7648 case right:
7649 if((int32_t(x)&15) > 7)
7650 x=(int32_t(x)&0xF0)+16;
7651 else
7652 x=(int32_t(x)&0xF0);
7653
7654 break;
7655 }
7656
7657 sclk=0;
7658 clk3=0;
7659 }
7660
7661 if((sclk&255)==0)
7662 sclk=0;
7663
7664 return true;
7665 }
7666
7667 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
7668 {
7669 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
7670 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
7671 bool ret = sprite::knockback(time, dir, speed);
7672 if(ret) sclk = 0; //kill engine knockback if interrupted
7673 //! Perhaps also set hitdir here, if needed for timing? -Z
7674 return ret;
7675 }
7676
7677 17937709 bool enemy::runKnockback()
7678 {
7679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17937709 times.
17937709 if((script_knockback_clk&0xFF)==0)
7680 {
7681 17937709 script_knockback_clk = 0;
7682 17937709 return false;
7683 }
7684 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
7685 {
7686 return false;
7687 }
7688 int32_t move = script_knockback_speed;
7689 int32_t kb_dir = script_knockback_clk>>8;
7690 --script_knockback_clk;
7691
7692 while(move>0)
7693 {
7694 int32_t thismove = zc_min(get_bit(quest_rules, qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
7695 move -= thismove;
7696 hitdir = kb_dir;
7697 switch(kb_dir)
7698 {
7699 case r_up:
7700 case l_up:
7701 case up:
7702 y-=thismove;
7703 break;
7704
7705 case r_down:
7706 case l_down:
7707 case down:
7708 y+=thismove;
7709 break;
7710 }
7711 switch(kb_dir)
7712 {
7713 case l_up:
7714 case l_down:
7715 case left:
7716 x-=thismove;
7717 break;
7718
7719 case r_up:
7720 case r_down:
7721 case right:
7722 x+=thismove;
7723 break;
7724 }
7725 if (get_bit(quest_rules, qr_OLD_SCRIPTED_KNOCKBACK))
7726 {
7727 if(!canmove(kb_dir,(zfix)0,0,true))
7728 {
7729 script_knockback_clk=0;
7730 clk3=0;
7731 //Fix to grid
7732 switch(kb_dir)
7733 {
7734 case up:
7735 case down:
7736 break;
7737 default:
7738 if(x < 0)
7739 x = 0;
7740 else if((int32_t(x)&15) > 7)
7741 x=(int32_t(x)&0xF0)+16;
7742 else
7743 x=(int32_t(x)&0xF0);
7744 break;
7745 }
7746 switch(kb_dir)
7747 {
7748 case left:
7749 case right:
7750 break;
7751 default:
7752 if(y < 0)
7753 y = 0;
7754 else if((int32_t(y)&15) > 7)
7755 y=(int32_t(y)&0xF0)+16;
7756 else
7757 y=(int32_t(y)&0xF0);
7758 break;
7759 }
7760 break;
7761 }
7762 }
7763 else
7764 {
7765 if(!scr_canplace(x,y,0,true))
7766 {
7767 script_knockback_clk=0;
7768 clk3=0;
7769 //Fix to grid
7770 if (OFFGRID_ENEMY)
7771 {
7772 switch(kb_dir)
7773 {
7774 case up:
7775 case down:
7776 break;
7777 default:
7778 if(x < 0)
7779 x = 0;
7780 else if((int32_t(x)&7) > 3)
7781 x=(int32_t(x)&0xF8)+8;
7782 else
7783 x=(int32_t(x)&0xF8);
7784 break;
7785 }
7786 switch(kb_dir)
7787 {
7788 case left:
7789 case right:
7790 break;
7791 default:
7792 if(y < 0)
7793 y = 0;
7794 else if((int32_t(y)&7) > 3)
7795 y=(int32_t(y)&0xF8)+8;
7796 else
7797 y=(int32_t(y)&0xF8);
7798 break;
7799 }
7800 }
7801 else
7802 {
7803 switch(kb_dir)
7804 {
7805 case up:
7806 case down:
7807 break;
7808 default:
7809 if(x < 0)
7810 x = 0;
7811 else if((int32_t(x)&15) > 7)
7812 x=(int32_t(x)&0xF0)+16;
7813 else
7814 x=(int32_t(x)&0xF0);
7815 break;
7816 }
7817 switch(kb_dir)
7818 {
7819 case left:
7820 case right:
7821 break;
7822 default:
7823 if(y < 0)
7824 y = 0;
7825 else if((int32_t(y)&15) > 7)
7826 y=(int32_t(y)&0xF0)+16;
7827 else
7828 y=(int32_t(y)&0xF0);
7829 break;
7830 }
7831 }
7832 break;
7833 }
7834
7835 }
7836 }
7837 return true;
7838 17937709 }
7839 // changes enemy's direction, checking restrictions
7840 // rate: 0 = no random changes, 16 = always random change
7841 // homing: 0 = none, 256 = always
7842 // grumble 0 = none, 4 = strongest appetite
7843 263068 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
7844 {
7845 263068 int32_t ndir=-1;
7846
7847
4/4
✓ Branch 0 taken 58307 times.
✓ Branch 1 taken 204761 times.
✓ Branch 2 taken 21048 times.
✓ Branch 3 taken 37259 times.
263068 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join.
7848 {
7849 37259 int32_t i = Lwpns.idFirst(wBait);
7850
1/2
✓ Branch 0 taken 37259 times.
✗ Branch 1 not taken.
37259 if(i >= 0) //idfirst returns -1 if it can't find any
7851 {
7852 weapon *w = (weapon*)Lwpns.spr(i);
7853 if (get_bit(quest_rules, qr_FIND_CLOSEST_BAIT))
7854 {
7855 int32_t currentrange;
7856 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
7857 else currentrange = -1;
7858 int curid = i;
7859 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
7860 for(; i<Lwpns.Count(); ++i)
7861 {
7862 weapon *lw = (weapon*)Lwpns.spr(i);
7863 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
7864 {
7865 currentrange = distance(x, y, lw->x, lw->y);
7866 curid = i;
7867 }
7868 }
7869 i = curid;
7870 if (currentrange == -1) i = -1;
7871 }
7872 else
7873 {
7874 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
7875 }
7876 if (i >= 0)
7877 {
7878 int32_t bx = Lwpns.spr(i)->x;
7879 int32_t by = Lwpns.spr(i)->y;
7880
7881 if(abs(int32_t(y)-by)>14)
7882 {
7883 ndir = (by<y) ? up : down;
7884 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
7885 if(canmove(ndir,special,false))
7886 {
7887 dir=ndir;
7888 return;
7889 }
7890 }
7891
7892 ndir = (bx<x) ? left : right;
7893 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
7894 if(canmove(ndir,special,false))
7895 {
7896 dir=ndir;
7897 return;
7898 }
7899 }
7900 }
7901 37259 }
7902
7903
2/2
✓ Branch 0 taken 181691 times.
✓ Branch 1 taken 81377 times.
263068 if((zc_oldrand()&255)<abs(newhoming))
7904 {
7905 81377 ndir = lined_up(8,false);
7906
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 81377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
81377 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
7907
4/4
✓ Branch 0 taken 21557 times.
✓ Branch 1 taken 59820 times.
✓ Branch 2 taken 2803 times.
✓ Branch 3 taken 18754 times.
81377 if(ndir>=0 && canmove(ndir,special,false))
7908 {
7909 18754 dir=ndir;
7910 18754 return;
7911 }
7912 62623 }
7913
7914 244314 int32_t i=0;
7915
7916
2/2
✓ Branch 0 taken 1057 times.
✓ Branch 1 taken 540513 times.
541570 for(; i<32; i++)
7917 {
7918 540513 int32_t r=zc_oldrand();
7919
7920
2/2
✓ Branch 0 taken 164411 times.
✓ Branch 1 taken 376102 times.
540513 if((r&15)<newrate)
7921 164411 ndir=(r>>4)&3;
7922 else
7923 376102 ndir=dir;
7924
7925
2/2
✓ Branch 0 taken 297256 times.
✓ Branch 1 taken 243257 times.
540513 if(canmove(ndir,special,false))
7926 243257 break;
7927 297256 }
7928
7929
2/2
✓ Branch 0 taken 243257 times.
✓ Branch 1 taken 1057 times.
244698 if(i==32)
7930 {
7931
2/2
✓ Branch 0 taken 3053 times.
✓ Branch 1 taken 384 times.
3437 for(ndir=0; ndir<4; ndir++)
7932 {
7933
2/2
✓ Branch 0 taken 2380 times.
✓ Branch 1 taken 673 times.
3053 if(canmove(ndir,special,false))
7934 673 goto ok;
7935 2380 }
7936
7937
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 324 times.
384 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
7938 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
7939 384 }
7940
7941 ok:
7942 244314 dir = ndir;
7943 263068 }
7944
7945 873 void enemy::newdir()
7946 {
7947 873 newdir(4,0,spw_none);
7948 873 }
7949
7950 zfix enemy::distance_left()
7951 {
7952 int32_t a2=x.getInt();
7953 int32_t b2=y.getInt();
7954
7955 switch(dir)
7956 {
7957 case up:
7958 return (zfix)(b2&0xF);
7959
7960 case down:
7961 return (zfix)(16-(b2&0xF));
7962
7963 case left:
7964 return (zfix)(a2&0xF);
7965
7966 case right:
7967 return (zfix)(16-(a2&0xF));
7968 }
7969
7970 return (zfix)0;
7971 }
7972
7973 // keeps walking around
7974 183724 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
7975 {
7976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 183724 times.
183724 if(slide())
7977 return;
7978
7979
8/12
✓ Branch 0 taken 181667 times.
✓ Branch 1 taken 2057 times.
✓ Branch 2 taken 181667 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 179952 times.
✓ Branch 5 taken 1715 times.
✓ Branch 6 taken 179952 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 179952 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 179952 times.
183724 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
7980 3772 return;
7981
7982
2/2
✓ Branch 0 taken 11372 times.
✓ Branch 1 taken 168580 times.
179952 if(clk3<=0)
7983 {
7984 11372 fix_coords(true);
7985 11372 newdir(newrate,newhoming,special);
7986
7987
1/2
✓ Branch 0 taken 11372 times.
✗ Branch 1 not taken.
11372 if(step==0)
7988 clk3=0;
7989 else
7990 11372 clk3=int32_t(16.0/step);
7991 11372 }
7992
2/2
✓ Branch 0 taken 168561 times.
✓ Branch 1 taken 19 times.
168580 else if(scored)
7993 {
7994 19 dir^=1;
7995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if (step != 0) clk3=int32_t(16.0/step)-clk3;
7996 else clk3=32767;
7997 19 }
7998
7999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179952 times.
179952 if (step != 0) --clk3;
8000 179952 move(step);
8001 183724 }
8002
8003 void enemy::constant_walk()
8004 {
8005 constant_walk(4,0,spw_none);
8006 }
8007
8008 13569 int32_t enemy::pos(int32_t newx,int32_t newy)
8009 {
8010 13569 return (newy<<8)+newx;
8011 }
8012
8013 // for variable step rates
8014 195634 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
8015 {
8016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 195634 times.
195634 if(slide())
8017 return;
8018
8019
10/14
✓ Branch 0 taken 195634 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195634 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 191351 times.
✓ Branch 5 taken 4283 times.
✓ Branch 6 taken 184878 times.
✓ Branch 7 taken 6473 times.
✓ Branch 8 taken 165381 times.
✓ Branch 9 taken 19497 times.
✓ Branch 10 taken 165381 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 165381 times.
✗ Branch 13 not taken.
195634 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
8020 30253 return;
8021
8022 165381 zfix dx = (zfix)0;
8023 165381 zfix dy = (zfix)0;
8024
8025
4/9
✓ Branch 0 taken 37215 times.
✓ Branch 1 taken 38101 times.
✓ Branch 2 taken 44367 times.
✓ Branch 3 taken 45698 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
165381 switch(dir)
8026 {
8027 case 8:
8028 case up:
8029 37215 dy-=step;
8030 37215 break;
8031
8032 case 12:
8033 case down:
8034 38101 dy+=step;
8035 38101 break;
8036
8037 case 14:
8038 case left:
8039 44367 dx-=step;
8040 44367 break;
8041
8042 case 10:
8043 case right:
8044 45698 dx+=step;
8045 45698 break;
8046
8047 case 15:
8048 case l_up:
8049 dx-=step;
8050 dy-=step;
8051 break;
8052
8053 case 9:
8054 case r_up:
8055 dx+=step;
8056 dy-=step;
8057 break;
8058
8059 case 13:
8060 case l_down:
8061 dx-=step;
8062 dy+=step;
8063 break;
8064
8065 case 11:
8066 case r_down:
8067 dx+=step;
8068 dy+=step;
8069 break;
8070 }
8071
8072
8/8
✓ Branch 0 taken 79785 times.
✓ Branch 1 taken 85596 times.
✓ Branch 2 taken 8462 times.
✓ Branch 3 taken 71323 times.
✓ Branch 4 taken 4541 times.
✓ Branch 5 taken 3921 times.
✓ Branch 6 taken 160274 times.
✓ Branch 7 taken 5107 times.
165381 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
8073 160840 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
8074 {
8075 5107 fix_coords();
8076 5107 newdir(newrate,newhoming,special);
8077 5107 clk3=pos(x,y);
8078 5107 }
8079
8080 165381 move(step);
8081 195634 }
8082
8083 // pauses for a while after it makes a complete move (to a new square)
8084 6432436 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
8085 {
8086
4/4
✓ Branch 0 taken 36848 times.
✓ Branch 1 taken 6395588 times.
✓ Branch 2 taken 29310 times.
✓ Branch 3 taken 7538 times.
6432436 if(sclk && clk2)
8087 {
8088 7538 clk3=0;
8089 7538 }
8090
8091
11/14
✓ Branch 0 taken 6400378 times.
✓ Branch 1 taken 32058 times.
✓ Branch 2 taken 6400378 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6400378 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6150762 times.
✓ Branch 7 taken 249616 times.
✓ Branch 8 taken 6030130 times.
✓ Branch 9 taken 120632 times.
✓ Branch 10 taken 6028358 times.
✓ Branch 11 taken 1772 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 6028358 times.
6432436 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8092 {
8093 404078 return;
8094 }
8095
8096
2/2
✓ Branch 0 taken 1208506 times.
✓ Branch 1 taken 4819852 times.
6028358 if(clk2>0)
8097 {
8098 1208506 --clk2;
8099 1208506 return;
8100 }
8101
8102
2/2
✓ Branch 0 taken 212448 times.
✓ Branch 1 taken 4607404 times.
4819852 if(clk3<=0)
8103 {
8104 212448 fix_coords(true);
8105 212448 newdir(newrate,newhoming,special);
8106 212448 clk3=int32_t(16.0/step);
8107
2/2
✓ Branch 0 taken 212440 times.
✓ Branch 1 taken 8 times.
212448 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
8108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 212448 times.
212448 if(clk2<0)
8109 {
8110 clk2=0;
8111 }
8112
2/2
✓ Branch 0 taken 29526 times.
✓ Branch 1 taken 182922 times.
212448 else if((zc_oldrand()&15)<newhrate)
8113 {
8114 29526 clk2=haltcnt;
8115 29526 return;
8116 }
8117 182922 }
8118
2/2
✓ Branch 0 taken 4606162 times.
✓ Branch 1 taken 1242 times.
4607404 else if(scored)
8119 {
8120 1242 dir^=1;
8121
8122
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1241 times.
1242 if (step != 0) clk3=int32_t(16.0/step)-clk3;
8123 1 else clk3=32767;
8124 1242 }
8125
8126
2/2
✓ Branch 0 taken 11925 times.
✓ Branch 1 taken 4778401 times.
4790326 if (step != 0) --clk3;
8127 4790326 move(step);
8128 6432436 }
8129
8130 // 8-directional movement, aligns to 8 pixels
8131 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
8132 {
8133 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8134 return;
8135
8136 if(clk3<=0)
8137 {
8138 newdir_8(newrate,newhoming,special);
8139 clk3=int32_t(8.0/step);
8140 if (step == 0) clk3 = 32767;
8141 }
8142
8143 if (step != 0) --clk3;
8144 move(step);
8145 }
8146 // 8-directional movement, aligns to 8 pixels
8147 78326 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
8148 {
8149
6/12
✓ Branch 0 taken 78326 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 78326 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78326 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 78326 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 78326 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 78326 times.
78326 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8150 return;
8151
8152
2/2
✓ Branch 0 taken 72597 times.
✓ Branch 1 taken 5729 times.
78326 if(clk3<=0)
8153 {
8154 5729 newdir_8(newrate,newhoming,special);
8155 5729 clk3=int32_t(8.0/step);
8156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5729 times.
5729 if (step == 0) clk3 = 32767;
8157 5729 }
8158
8159
1/2
✓ Branch 0 taken 78326 times.
✗ Branch 1 not taken.
78326 if (step != 0) --clk3;
8160 78326 move(step);
8161 78326 }
8162
8163 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
8164 {
8165 if(clk<0 || dying || stunclk || watch || frozenclock)
8166 return;
8167
8168 if(!canmove(dir,step,special,false))
8169 clk3=0;
8170
8171 if(clk2>0)
8172 {
8173 --clk2;
8174 return;
8175 }
8176
8177 if(clk3<=0)
8178 {
8179 newdir_8(newrate,newhoming,special);
8180 clk3=newclk;
8181
8182 if(clk2<0)
8183 {
8184 clk2=0;
8185 }
8186 else if((zc_oldrand()&15)<newhrate)
8187 {
8188 newdir_8(newrate,newhoming,special);
8189 clk2=haltcnt;
8190 return;
8191 }
8192 }
8193
8194 --clk3;
8195 move(step);
8196 }
8197
8198 // 8-directional movement, no alignment
8199 2177599 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
8200 {
8201
9/12
✓ Branch 0 taken 2089308 times.
✓ Branch 1 taken 88291 times.
✓ Branch 2 taken 2089308 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2068241 times.
✓ Branch 5 taken 21067 times.
✓ Branch 6 taken 2059338 times.
✓ Branch 7 taken 8903 times.
✓ Branch 8 taken 2059338 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2059338 times.
2177599 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8202 118261 return;
8203
8204
2/2
✓ Branch 0 taken 2044716 times.
✓ Branch 1 taken 14622 times.
2059338 if(!canmove(dir,step,special,false))
8205 14622 clk3=0;
8206
8207
2/2
✓ Branch 0 taken 1798778 times.
✓ Branch 1 taken 260560 times.
2059338 if(clk3<=0)
8208 {
8209 260560 newdir_8(newrate,newhoming,special);
8210 260560 clk3=newclk;
8211 260560 }
8212
8213 2059338 --clk3;
8214 2059338 move(step);
8215 2177599 }
8216
8217 // same as above but with variable enemy size
8218 51094 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
8219 {
8220
8/12
✓ Branch 0 taken 50372 times.
✓ Branch 1 taken 722 times.
✓ Branch 2 taken 50372 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50372 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50321 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 50321 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 50321 times.
51094 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8221 773 return;
8222
8223
2/2
✓ Branch 0 taken 49815 times.
✓ Branch 1 taken 506 times.
50321 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
8224 506 clk3=0;
8225
8226
2/2
✓ Branch 0 taken 46936 times.
✓ Branch 1 taken 3385 times.
50321 if(clk3<=0)
8227 {
8228 3385 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
8229 3385 clk3=newclk;
8230 3385 }
8231
8232 50321 --clk3;
8233 50321 move(step);
8234 51094 }
8235
8236 // the variable speed floater movement
8237 // ms is max speed
8238 // ss is step speed
8239 // s is step count
8240 // p is pause count
8241 // g is graduality :)
8242 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
8243 1803542 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8244 {
8245 1803542 ++clk2;
8246 1803542 byte over_pit = overpit(this);
8247
8248
4/4
✓ Branch 0 taken 410894 times.
✓ Branch 1 taken 1392648 times.
✓ Branch 2 taken 410627 times.
✓ Branch 3 taken 267 times.
1803542 if(dmisc1 && over_pit) p = 0;
8249
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 33094 times.
✓ Branch 2 taken 686179 times.
✓ Branch 3 taken 1009450 times.
✓ Branch 4 taken 74819 times.
1803542 switch(movestatus)
8250 {
8251 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
8252 //! if the conditions prevent it, we jump back to case 2.
8253 case 0: // paused
8254
2/2
✓ Branch 0 taken 32451 times.
✓ Branch 1 taken 643 times.
33094 if(clk2>=p)
8255 {
8256 643 movestatus=1;
8257 643 clk2=0;
8258 643 }
8259
8260 33094 break;
8261
8262 case 1: // speeding up
8263
1/2
✓ Branch 0 taken 686179 times.
✗ Branch 1 not taken.
686179 if (s >= 0)
8264 {
8265
2/2
✓ Branch 0 taken 681452 times.
✓ Branch 1 taken 4727 times.
686179 if(clk2<g*s)
8266 {
8267
2/2
✓ Branch 0 taken 637876 times.
✓ Branch 1 taken 43576 times.
681452 if(!((clk2-1)%g))
8268 43576 step+=ss;
8269 681452 }
8270 else
8271 {
8272 4727 movestatus=2;
8273 4727 clk2=0;
8274 }
8275 686179 }
8276 else
8277 {
8278 if(step < ms)
8279 {
8280 if(!((clk2-1)%g))
8281 {
8282 step+=ss;
8283 if (step >= ms) step = ms;
8284 }
8285 }
8286 else
8287 {
8288 step = ms;
8289 movestatus=2;
8290 clk2=0;
8291 }
8292 }
8293
8294 686179 break;
8295
8296 case 2: // normal
8297 1009450 step=ms;
8298
8299
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1009450 times.
✓ Branch 2 taken 204256 times.
✓ Branch 3 taken 805194 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 805194 times.
✓ Branch 6 taken 804133 times.
✓ Branch 7 taken 1061 times.
1009450 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
8300 {
8301
1/2
✓ Branch 0 taken 1061 times.
✗ Branch 1 not taken.
1061 if (s >= 0) step=ss*s;
8302 else step=ms;
8303 1061 movestatus=3;
8304 1061 clk2=0;
8305 1061 }
8306
8307 1009450 break;
8308
8309 case 3: // slowing down
8310
1/2
✓ Branch 0 taken 74819 times.
✗ Branch 1 not taken.
74819 if (s >= 0)
8311 {
8312
2/2
✓ Branch 0 taken 74059 times.
✓ Branch 1 taken 760 times.
74819 if(clk2<=g*s)
8313 {
8314 { //don't slow down over pits
8315
8316
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 74047 times.
74059 if(over_pit)
8317 {
8318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(dmisc1)
8319 {
8320 step=ms;
8321 }
8322 12 }
8323 else //can slow down
8324 {
8325
4/4
✓ Branch 0 taken 4601 times.
✓ Branch 1 taken 69446 times.
✓ Branch 2 taken 4329 times.
✓ Branch 3 taken 272 times.
74047 if(!(clk2%g) && !dmisc1)
8326 4329 step-=ss;
8327 }
8328 }
8329
8330
8331 74059 }
8332 else
8333 {
8334 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
8335 //this doesn't help keese, as they have a z of 0.
8336 //they always nee to run this check.
8337 {
8338
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
760 if(over_pit &&!dmisc1)
8339 {
8340 --clk2; //if over a pit, don't land, and revert clock change
8341 }
8342 else //can land safely
8343 {
8344 760 movestatus=0;
8345
3/4
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 314 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 446 times.
760 if(dmisc1&&!over_pit)
8346 446 step=0;
8347 760 clk2=0;
8348 }
8349 }
8350
8351 }
8352 74819 }
8353 else
8354 {
8355 if(step > 0)
8356 {
8357 if(over_pit)
8358 {
8359 if(dmisc1)
8360 {
8361 step=ms;
8362 }
8363 }
8364 else //can slow down
8365 {
8366 if(!(clk2%g))
8367 step-=ss;
8368 }
8369 }
8370 else
8371 {
8372 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
8373 //this doesn't help keese, as they have a z of 0.
8374 //they always nee to run this check.
8375 if(over_pit)
8376 {
8377 step+=ss; //if over a pit, don't land, and revert clock change
8378 }
8379 else //can land safely
8380 {
8381 movestatus=0;
8382 step=0;
8383 clk2=0;
8384 }
8385 }
8386 }
8387
8388 74819 break;
8389 }
8390
8391
2/2
✓ Branch 0 taken 1013116 times.
✓ Branch 1 taken 790426 times.
1803542 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
8392 1803542 }
8393
8394 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
8395 {
8396 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
8397 }
8398
8399 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
8400 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
8401 441306 int32_t enemy::lined_up(int32_t range, bool dir8)
8402 {
8403 441306 int32_t lx = Hero.getX();
8404 441306 int32_t ly = Hero.getY();
8405
8406
2/2
✓ Branch 0 taken 16903 times.
✓ Branch 1 taken 424403 times.
441306 if(abs(lx-int32_t(x))<=range)
8407 {
8408
2/2
✓ Branch 0 taken 6472 times.
✓ Branch 1 taken 10431 times.
16903 if(ly<y)
8409 {
8410 6472 return up;
8411 }
8412
8413 10431 return down;
8414 }
8415
8416
2/2
✓ Branch 0 taken 19553 times.
✓ Branch 1 taken 404850 times.
424403 if(abs(ly-int32_t(y))<=range)
8417 {
8418
2/2
✓ Branch 0 taken 9810 times.
✓ Branch 1 taken 9743 times.
19553 if(lx<x)
8419 {
8420 9810 return left;
8421 }
8422
8423 9743 return right;
8424 }
8425
8426
2/2
✓ Branch 0 taken 78467 times.
✓ Branch 1 taken 326383 times.
404850 if(dir8)
8427 {
8428
2/2
✓ Branch 0 taken 112565 times.
✓ Branch 1 taken 213818 times.
326383 if(abs(lx-x)-abs(ly-y)<=range)
8429 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
8430 {
8431
2/2
✓ Branch 0 taken 49585 times.
✓ Branch 1 taken 62980 times.
112565 if(ly<y)
8432 {
8433
2/2
✓ Branch 0 taken 29028 times.
✓ Branch 1 taken 20557 times.
49585 if(lx<x)
8434 {
8435 29028 return l_up;
8436 }
8437 else
8438 {
8439 20557 return r_up;
8440 }
8441 }
8442 else
8443 {
8444
2/2
✓ Branch 0 taken 30910 times.
✓ Branch 1 taken 32070 times.
62980 if(lx<x)
8445 {
8446 32070 return l_down;
8447 }
8448 else
8449 {
8450 30910 return r_down;
8451 }
8452 }
8453 }
8454 213818 }
8455
8456 292285 return -1;
8457 441306 }
8458
8459 // returns true if Hero is within 'range' pixels of the enemy
8460 13559 bool enemy::HeroInRange(int32_t range)
8461 {
8462 13559 int32_t lx = Hero.getX();
8463 13559 int32_t ly = Hero.getY();
8464
2/2
✓ Branch 0 taken 11346 times.
✓ Branch 1 taken 2213 times.
13559 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
8465 }
8466
8467 // place the enemy in line with Hero (red wizzrobes)
8468 2098 void enemy::place_on_axis(bool floater, bool solid_ok)
8469 {
8470
6/6
✓ Branch 0 taken 1740 times.
✓ Branch 1 taken 358 times.
✓ Branch 2 taken 1913 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 1555 times.
✓ Branch 5 taken 358 times.
2098 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
8471
6/6
✓ Branch 0 taken 1735 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 1815 times.
✓ Branch 3 taken 283 times.
✓ Branch 4 taken 1452 times.
✓ Branch 5 taken 363 times.
2098 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
8472 2098 int32_t pos2=zc_oldrand()%23;
8473 2098 int32_t tried=0;
8474 2098 bool last_resort,placed=false;
8475
8476
8477 2098 do
8478 {
8479
2/2
✓ Branch 0 taken 2124 times.
✓ Branch 1 taken 1492 times.
3616 if(pos2<14)
8480 {
8481 2124 x=(pos2<<4)+16;
8482 2124 y=ly;
8483 2124 }
8484 else
8485 {
8486 1492 x=lx;
8487 1492 y=((pos2-14)<<4)+16;
8488 }
8489
8490 // Don't commit to a last resort if position is out of bounds.
8491
6/6
✓ Branch 0 taken 3472 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 3331 times.
✓ Branch 3 taken 141 times.
✓ Branch 4 taken 109 times.
✓ Branch 5 taken 3222 times.
3616 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
8492
8493
4/4
✓ Branch 0 taken 1859 times.
✓ Branch 1 taken 1757 times.
✓ Branch 2 taken 3379 times.
✓ Branch 3 taken 2076 times.
3616 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
8494 {
8495 // Red Wizzrobes should be able to appear on water, but not other
8496 // solid combos; however, they could appear on solid combos in 2.10,
8497 // and some quests depend on that.
8498
4/4
✓ Branch 0 taken 1808 times.
✓ Branch 1 taken 3328 times.
✓ Branch 2 taken 1230 times.
✓ Branch 3 taken 2098 times.
5136 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
8499 5136 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
8500 2098 placed=true;
8501 5136 }
8502
8503
3/6
✓ Branch 0 taken 1518 times.
✓ Branch 1 taken 3398 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1518 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4916 if(!placed && tried>=22 && last_resort)
8504 {
8505 placed=true;
8506 }
8507
8508 4916 ++tried;
8509 4916 pos2=(pos2+3)%23;
8510
2/2
✓ Branch 0 taken 1518 times.
✓ Branch 1 taken 3398 times.
4916 }
8511 4916 while(!placed);
8512
8513
2/2
✓ Branch 0 taken 2636 times.
✓ Branch 1 taken 762 times.
3398 if(y==ly)
8514 2636 dir=(x<lx)?right:left;
8515 else
8516 762 dir=(y<ly)?down:up;
8517
8518 3398 clk2=tried;
8519 3398 }
8520
8521 9047067 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
8522 {
8523 9047067 int32_t t = o_tile;
8524 9047067 int32_t b = o_tile;
8525
8526 // Darknuts, but also Wizzrobes and Wallmasters
8527
3/4
✓ Branch 0 taken 3300387 times.
✓ Branch 1 taken 5404317 times.
✓ Branch 2 taken 342363 times.
✗ Branch 3 not taken.
9047067 switch(family)
8528 {
8529 case eeWALK:
8530
5/6
✓ Branch 0 taken 369324 times.
✓ Branch 1 taken 5034993 times.
✓ Branch 2 taken 261311 times.
✓ Branch 3 taken 108013 times.
✓ Branch 4 taken 261311 times.
✗ Branch 5 not taken.
5404317 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
8531 {
8532 261311 tile=s_tile;
8533 261311 t=s_tile;
8534 261311 b=s_tile;
8535 261311 }
8536
8537 5404317 break;
8538
8539 case eeTRAP:
8540
4/6
✓ Branch 0 taken 121158 times.
✓ Branch 1 taken 221205 times.
✓ Branch 2 taken 121158 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 121158 times.
342363 if(dummy_int[1] && guysbuf[id].flags2 & eneflag_trp2 && do_animation) // Just to make sure
8541 {
8542 121158 tile=s_tile;
8543 121158 t=s_tile;
8544 121158 b=s_tile;
8545 121158 }
8546
8547 342363 break;
8548
8549 case eeSPINTILE:
8550 if(misc>=96 && do_animation)
8551 {
8552 tile=o_tile+frames*ndir;
8553 t=tile;
8554 }
8555
8556 break;
8557 }
8558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9047067 times.
9047067 if ( do_animation )
8559 {
8560
4/6
✓ Branch 0 taken 151514 times.
✓ Branch 1 taken 8895553 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77420 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8818133 times.
9047067 if(ndir!=0) switch(frames)
8561 {
8562 case 2:
8563 77420 tiledir_small(dir,ndir==4);
8564 77420 break;
8565
8566 case 3:
8567 tiledir_three(dir);
8568 break;
8569
8570 case 4:
8571 8818133 tiledir(dir,ndir==4);
8572 8818133 break;
8573 8895553 }
8574
8575
2/2
✓ Branch 0 taken 5404317 times.
✓ Branch 1 taken 3642750 times.
9047067 if(family==eeWALK)
8576
6/6
✓ Branch 0 taken 4300380 times.
✓ Branch 1 taken 1103937 times.
✓ Branch 2 taken 4054888 times.
✓ Branch 3 taken 1349429 times.
✓ Branch 4 taken 1065375 times.
✓ Branch 5 taken 284054 times.
5404317 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
8577 else
8578 3642750 tile+=f4;
8579 9047067 }
8580 9047067 return b;
8581 }
8582
8583 void enemy::tiledir_three(int32_t ndir)
8584 {
8585 if ( !do_animation ) return;
8586 flip=0;
8587
8588 switch(ndir)
8589 {
8590 case right:
8591 tile+=3;
8592 [[fallthrough]];
8593
8594 case left:
8595 tile+=3;
8596 [[fallthrough]];
8597
8598 case down:
8599 tile+=3;
8600 [[fallthrough]];
8601
8602 case up:
8603 break;
8604 }
8605 }
8606
8607 77420 void enemy::tiledir_small(int32_t ndir, bool fourdir)
8608 {
8609
1/2
✓ Branch 0 taken 77420 times.
✗ Branch 1 not taken.
77420 if ( !do_animation ) return;
8610 77420 flip=0;
8611
8612
4/9
✓ Branch 0 taken 17011 times.
✓ Branch 1 taken 16756 times.
✓ Branch 2 taken 22057 times.
✓ Branch 3 taken 21596 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
77420 switch(ndir)
8613 {
8614 case 8:
8615 case up:
8616 17011 break;
8617
8618 case 12:
8619 case down:
8620 16756 tile+=2;
8621 16756 break;
8622
8623 case 14:
8624 case left:
8625 22057 tile+=4;
8626 22057 break;
8627
8628 case 10:
8629 case right:
8630 21596 tile+=6;
8631 21596 break;
8632
8633 case 9:
8634 case r_up:
8635 if(fourdir)
8636 break;
8637
8638 tile+=10;
8639 break;
8640
8641 case 11:
8642 case r_down:
8643 if(fourdir)
8644 tile+=2;
8645 else
8646 tile+=14;
8647
8648 break;
8649
8650 case 13:
8651 case l_down:
8652 if(fourdir)
8653 tile+=2;
8654 else
8655 tile+=12;
8656
8657 break;
8658
8659 case 15:
8660 case l_up:
8661 if(fourdir)
8662 break;
8663
8664 tile+=8;
8665 break;
8666
8667 default:
8668 //dir=(zc_oldrand()*100)%8;
8669 //tiledir_small(dir);
8670 // flip=zc_oldrand()&3;
8671 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
8672 break;
8673 }
8674 77420 }
8675
8676 10304163 void enemy::tiledir(int32_t ndir, bool fourdir)
8677 {
8678
1/2
✓ Branch 0 taken 10304163 times.
✗ Branch 1 not taken.
10304163 if ( !do_animation ) return;
8679 10304163 flip=0;
8680
8681
9/9
✓ Branch 0 taken 2064685 times.
✓ Branch 1 taken 1783418 times.
✓ Branch 2 taken 2453582 times.
✓ Branch 3 taken 2358461 times.
✓ Branch 4 taken 371164 times.
✓ Branch 5 taken 447500 times.
✓ Branch 6 taken 434629 times.
✓ Branch 7 taken 382443 times.
✓ Branch 8 taken 8281 times.
10304163 switch(ndir)
8682 {
8683 case 8:
8684 case up:
8685 2064685 break;
8686
8687 case 12:
8688 case down:
8689 1783418 tile+=4;
8690 1783418 break;
8691
8692 case 14:
8693 case left:
8694 2453582 tile+=8;
8695 2453582 break;
8696
8697 case 10:
8698 case right:
8699 2358461 tile+=12;
8700 2358461 break;
8701
8702 case 9:
8703 case r_up:
8704
2/2
✓ Branch 0 taken 53890 times.
✓ Branch 1 taken 317274 times.
371164 if(fourdir)
8705 53890 break;
8706 else
8707 317274 tile+=24;
8708
8709 317274 break;
8710
8711 case 11:
8712 case r_down:
8713
2/2
✓ Branch 0 taken 58873 times.
✓ Branch 1 taken 388627 times.
447500 if(fourdir)
8714 58873 tile+=4;
8715 else
8716 388627 tile+=32;
8717
8718 447500 break;
8719
8720 case 13:
8721 case l_down:
8722
2/2
✓ Branch 0 taken 61462 times.
✓ Branch 1 taken 373167 times.
434629 if(fourdir)
8723 61462 tile+=4;
8724 else
8725 373167 tile+=28;
8726
8727 434629 break;
8728
8729 case 15:
8730 case l_up:
8731
2/2
✓ Branch 0 taken 46534 times.
✓ Branch 1 taken 335909 times.
382443 if(fourdir)
8732 46534 break;
8733 else
8734 335909 tile+=20;
8735
8736 335909 break;
8737
8738 default:
8739 //dir=(zc_oldrand()*100)%8;
8740 //tiledir(dir);
8741 // flip=zc_oldrand()&3;
8742 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
8743 8281 break;
8744 }
8745 10304163 }
8746
8747 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
8748 {
8749
1/2
✓ Branch 0 taken 3868 times.
✗ Branch 1 not taken.
3868 if ( !do_animation ) return;
8750 3868 flip=0;
8751
8752
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
8753 {
8754 case 8:
8755 case up:
8756 297 break;
8757
8758 case 12:
8759 case down:
8760 tile+=8;
8761 break;
8762
8763 case 14:
8764 case left:
8765 195 tile+=40;
8766 195 break;
8767
8768 case 10:
8769 case right:
8770 179 tile+=48;
8771 179 break;
8772
8773 case 9:
8774 case r_up:
8775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
8776 break;
8777
8778 306 tile+=88;
8779 306 break;
8780
8781 case 11:
8782 case r_down:
8783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
8784 tile+=8;
8785 else
8786 1235 tile+=128;
8787
8788 1235 break;
8789
8790 case 13:
8791 case l_down:
8792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
8793 tile+=8;
8794 else
8795 1324 tile+=120;
8796
8797 1324 break;
8798
8799 case 15:
8800 case l_up:
8801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
8802 break;
8803
8804 332 tile+=80;
8805 332 break;
8806
8807 default:
8808 //dir=(zc_oldrand()*100)%8;
8809 //tiledir_big(dir);
8810 // flip=zc_oldrand()&3;
8811 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
8812 break;
8813 }
8814 3868 }
8815
8816 19547942 void enemy::update_enemy_frame()
8817 {
8818
3/4
✓ Branch 0 taken 19547800 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19547800 times.
19547942 if(fallclk||drownclk) return;
8819
1/2
✓ Branch 0 taken 19547800 times.
✗ Branch 1 not taken.
19547800 if (!do_animation)
8820 return;
8821
8822
3/4
✓ Branch 0 taken 152626 times.
✓ Branch 1 taken 19395174 times.
✓ Branch 2 taken 152626 times.
✗ Branch 3 not taken.
19547800 if (get_bit(quest_rules,qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
8823
8824
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
19547800 if(get_bit(quest_rules,qr_ANONE_NOANIM)
8825
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 19547800 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
19547800 && anim == aNONE && family != eeGUY)
8826 return;
8827
2/2
✓ Branch 0 taken 19234347 times.
✓ Branch 1 taken 313453 times.
19547800 int32_t newfrate = zc_max(frate,4);
8828 19547800 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
8829 19547800 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
8830
2/2
✓ Branch 0 taken 13327122 times.
✓ Branch 1 taken 6220678 times.
19547800 int32_t fx = get_bit(quest_rules, qr_NEWENEMYTILES) ? f4 : f2;
8831 19547800 tile = o_tile;
8832 19547800 int32_t basetile = o_tile;
8833 19547800 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
8834 19547800 bool ignore_extend = false;
8835
34/40
✓ Branch 0 taken 117019 times.
✓ Branch 1 taken 5459 times.
✓ Branch 2 taken 35552 times.
✓ Branch 3 taken 1156612 times.
✓ Branch 4 taken 216057 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 86767 times.
✓ Branch 7 taken 207174 times.
✓ Branch 8 taken 125758 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2285112 times.
✓ Branch 12 taken 34777 times.
✓ Branch 13 taken 48420 times.
✓ Branch 14 taken 818 times.
✓ Branch 15 taken 263084 times.
✓ Branch 16 taken 595734 times.
✓ Branch 17 taken 151514 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 74845 times.
✓ Branch 20 taken 143289 times.
✓ Branch 21 taken 401570 times.
✓ Branch 22 taken 918246 times.
✓ Branch 23 taken 706352 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 77420 times.
✓ Branch 26 taken 1902072 times.
✓ Branch 27 taken 3427398 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 346038 times.
✓ Branch 30 taken 676948 times.
✓ Branch 31 taken 523961 times.
✓ Branch 32 taken 128173 times.
✓ Branch 33 taken 1192542 times.
✓ Branch 34 taken 73931 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 3146848 times.
✓ Branch 37 taken 281552 times.
✓ Branch 38 taken 156657 times.
✓ Branch 39 taken 36233 times.
19547800 switch(anim)
8836 {
8837
8838 case aDONGO:
8839 {
8840 34777 int32_t fr = stunclk>0 ? 16 : 8;
8841
8842
6/6
✓ Branch 0 taken 33445 times.
✓ Branch 1 taken 1332 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 29125 times.
✓ Branch 4 taken 1440 times.
✓ Branch 5 taken 2880 times.
34777 if(!dying && clk2>0 && clk2<=64)
8843 {
8844 // bloated
8845
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 768 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1088 times.
✓ Branch 4 taken 640 times.
2880 switch(dir)
8846 {
8847 case up:
8848 768 tile+=9;
8849 768 flip=0;
8850 768 xofs=0;
8851 768 dummy_int[1]=0; //no additional tiles
8852 768 break;
8853
8854 case down:
8855 384 tile+=7;
8856 384 flip=0;
8857 384 xofs=0;
8858 384 dummy_int[1]=0; //no additional tiles
8859 384 break;
8860
8861 case left:
8862 1088 flip=1;
8863 1088 tile+=4;
8864 1088 xofs=16;
8865 1088 dummy_int[1]=1; //second tile is next tile
8866 1088 break;
8867
8868 case right:
8869 640 flip=0;
8870 640 tile+=5;
8871 640 xofs=16;
8872 640 dummy_int[1]=-1; //second tile is previous tile
8873 640 break;
8874 }
8875 2880 }
8876
4/4
✓ Branch 0 taken 1332 times.
✓ Branch 1 taken 30565 times.
✓ Branch 2 taken 639 times.
✓ Branch 3 taken 693 times.
31897 else if(!dying || clk2>19)
8877 {
8878 // normal
8879
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 6641 times.
✓ Branch 2 taken 7017 times.
✓ Branch 3 taken 10395 times.
✓ Branch 4 taken 7151 times.
31204 switch(dir)
8880 {
8881 case up:
8882 6641 tile+=8;
8883 6641 flip=(clk&fr)?1:0;
8884 6641 xofs=0;
8885 6641 dummy_int[1]=0; //no additional tiles
8886 6641 break;
8887
8888 case down:
8889 7017 tile+=6;
8890 7017 flip=(clk&fr)?1:0;
8891 7017 xofs=0;
8892 7017 dummy_int[1]=0; //no additional tiles
8893 7017 break;
8894
8895 case left:
8896 10395 flip=1;
8897 10395 tile+=(clk&fr)?2:0;
8898 10395 xofs=16;
8899 10395 dummy_int[1]=1; //second tile is next tile
8900 10395 break;
8901
8902 case right:
8903 7151 flip=0;
8904 7151 tile+=(clk&fr)?3:1;
8905 7151 xofs=16;
8906 7151 dummy_int[1]=-1; //second tile is next tile
8907 7151 break;
8908 }
8909 31204 }
8910 }
8911 34777 break;
8912
8913 case aNEWDONGO:
8914 {
8915 48420 int32_t fr4=0;
8916
8917
6/6
✓ Branch 0 taken 46728 times.
✓ Branch 1 taken 1692 times.
✓ Branch 2 taken 3648 times.
✓ Branch 3 taken 43080 times.
✓ Branch 4 taken 1216 times.
✓ Branch 5 taken 2432 times.
48420 if(!dying && clk2>0 && clk2<=64)
8918 {
8919 // bloated
8920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2432 times.
2432 if(clk2>=0)
8921 {
8922 2432 fr4=3;
8923 2432 }
8924
8925
2/2
✓ Branch 0 taken 570 times.
✓ Branch 1 taken 1862 times.
2432 if(clk2>=16)
8926 {
8927 1862 fr4=2;
8928 1862 }
8929
8930
2/2
✓ Branch 0 taken 1178 times.
✓ Branch 1 taken 1254 times.
2432 if(clk2>=32)
8931 {
8932 1254 fr4=1;
8933 1254 }
8934
8935
2/2
✓ Branch 0 taken 1786 times.
✓ Branch 1 taken 646 times.
2432 if(clk2>=48)
8936 {
8937 646 fr4=0;
8938 646 }
8939
8940
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1024 times.
2432 switch(dir)
8941 {
8942 case up:
8943 256 xofs=0;
8944 256 tile+=8+fr4;
8945 256 dummy_int[1]=0; //no additional tiles
8946 256 break;
8947
8948 case down:
8949 576 xofs=0;
8950 576 tile+=12+fr4;
8951 576 dummy_int[1]=0; //no additional tiles
8952 576 break;
8953
8954 case left:
8955 576 tile+=29+(2*fr4);
8956 576 xofs=16;
8957 576 dummy_int[1]=-1; //second tile is previous tile
8958 576 break;
8959
8960 case right:
8961 1024 tile+=49+(2*fr4);
8962 1024 xofs=16;
8963 1024 dummy_int[1]=-1; //second tile is previous tile
8964 1024 break;
8965 }
8966 2432 }
8967
4/4
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 44296 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 769 times.
45988 else if(!dying || clk2>19)
8968 {
8969 // normal
8970
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8569 times.
✓ Branch 2 taken 8925 times.
✓ Branch 3 taken 13235 times.
✓ Branch 4 taken 14490 times.
45219 switch(dir)
8971 {
8972 case up:
8973 8569 xofs=0;
8974 8569 tile+=((clk&12)>>2);
8975 8569 dummy_int[1]=0; //no additional tiles
8976 8569 break;
8977
8978 case down:
8979 8925 xofs=0;
8980 8925 tile+=4+((clk&12)>>2);
8981 8925 dummy_int[1]=0; //no additional tiles
8982 8925 break;
8983
8984 case left:
8985 13235 tile+=21+((clk&12)>>1);
8986 13235 xofs=16;
8987 13235 dummy_int[1]=-1; //second tile is previous tile
8988 13235 break;
8989
8990 case right:
8991 14490 flip=0;
8992 14490 tile+=41+((clk&12)>>1);
8993 14490 xofs=16;
8994 14490 dummy_int[1]=-1; //second tile is previous tile
8995 14490 break;
8996 }
8997 45219 }
8998 }
8999 48420 break;
9000
9001 case aDONGOBS:
9002 {
9003 818 int32_t fr4=0;
9004
9005
6/6
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 590 times.
✓ Branch 4 taken 64 times.
✓ Branch 5 taken 128 times.
818 if(!dying && clk2>0 && clk2<=64)
9006 {
9007 // bloated
9008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(clk2>=0)
9009 {
9010 128 fr4=3;
9011 128 }
9012
9013
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(clk2>=16)
9014 {
9015 98 fr4=2;
9016 98 }
9017
9018
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 66 times.
128 if(clk2>=32)
9019 {
9020 66 fr4=1;
9021 66 }
9022
9023
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 34 times.
128 if(clk2>=48)
9024 {
9025 34 fr4=0;
9026 34 }
9027
9028
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
128 switch(dir)
9029 {
9030 case up:
9031 tile+=28+fr4;
9032 yofs+=8;
9033 dummy_int[1]=-20; //second tile change
9034 dummy_int[2]=0; //new xofs change
9035 dummy_int[3]=-16; //new xofs change
9036 break;
9037
9038 case down:
9039 tile+=12+fr4;
9040 yofs-=8;
9041 dummy_int[1]=20; //second tile change
9042 dummy_int[2]=0; //new xofs change
9043 dummy_int[3]=16; //new xofs change
9044 break;
9045
9046 case left:
9047 128 tile+=49+(2*fr4);
9048 128 xofs+=8;
9049 128 dummy_int[1]=-1; //second tile change
9050 128 dummy_int[2]=-16; //new xofs change
9051 128 dummy_int[3]=0; //new xofs change
9052 128 break;
9053
9054 case right:
9055 tile+=69+(2*fr4);
9056 xofs+=8;
9057 dummy_int[1]=-1; //second tile change
9058 dummy_int[2]=-16; //new xofs change
9059 dummy_int[3]=0; //new xofs change
9060 break;
9061 }
9062 128 }
9063
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
690 else if(!dying || clk2>19)
9064 {
9065 // normal
9066
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 129 times.
✓ Branch 3 taken 332 times.
✓ Branch 4 taken 97 times.
654 switch(dir)
9067 {
9068 case up:
9069 96 tile+=20+((clk&24)>>3);
9070 96 yofs+=8;
9071 96 dummy_int[1]=-20; //second tile change
9072 96 dummy_int[2]=0; //new xofs change
9073 96 dummy_int[3]=-16; //new xofs change
9074 96 break;
9075
9076 case down:
9077 129 tile+=4+((clk&24)>>3);
9078 129 yofs-=8;
9079 129 dummy_int[1]=20; //second tile change
9080 129 dummy_int[2]=0; //new xofs change
9081 129 dummy_int[3]=16; //new xofs change
9082 129 break;
9083
9084 case left:
9085 332 xofs=-8;
9086 332 tile+=40+((clk&24)>>2);
9087 332 dummy_int[1]=1; //second tile change
9088 332 dummy_int[2]=16; //new xofs change
9089 332 dummy_int[3]=0; //new xofs change
9090 332 break;
9091
9092 case right:
9093 97 tile+=60+((clk&24)>>2);
9094 97 xofs=-8;
9095 97 dummy_int[1]=1; //second tile change
9096 97 dummy_int[2]=16; //new xofs change
9097 97 dummy_int[3]=0; //new xofs change
9098 97 break;
9099 }
9100 654 }
9101 }
9102 818 break;
9103
9104 case aWIZZ:
9105 {
9106 // if(d->misc1)
9107
2/2
✓ Branch 0 taken 78269 times.
✓ Branch 1 taken 184815 times.
263084 if(dmisc1)
9108 {
9109
2/2
✓ Branch 0 taken 39457 times.
✓ Branch 1 taken 38812 times.
78269 if(clk&8)
9110 {
9111 38812 ++tile;
9112 38812 }
9113 78269 }
9114 else
9115 {
9116
2/2
✓ Branch 0 taken 92464 times.
✓ Branch 1 taken 92351 times.
184815 if(frame&4)
9117 {
9118 92351 ++tile;
9119 92351 }
9120 }
9121
9122
4/4
✓ Branch 0 taken 44553 times.
✓ Branch 1 taken 86763 times.
✓ Branch 2 taken 88062 times.
✓ Branch 3 taken 43706 times.
263084 switch(dir)
9123 {
9124 case 9:
9125 case 15:
9126 case up:
9127 44553 tile+=2;
9128 44553 break;
9129
9130 case down:
9131 43706 break;
9132
9133 case 13:
9134 case left:
9135 86763 flip=1;
9136 86763 break;
9137
9138 default:
9139 88062 flip=0;
9140 88062 break;
9141 }
9142 }
9143 263084 break;
9144
9145 case aNEWWIZZ:
9146 {
9147 595734 tiledir(dir,true);
9148
9149 // if(d->misc1) //walking wizzrobe
9150
2/2
✓ Branch 0 taken 316790 times.
✓ Branch 1 taken 278944 times.
595734 if(dmisc1) //walking wizzrobe
9151 {
9152
2/2
✓ Branch 0 taken 159200 times.
✓ Branch 1 taken 157590 times.
316790 if(clk&8)
9153 {
9154 157590 tile+=2;
9155 157590 }
9156
9157
2/2
✓ Branch 0 taken 158616 times.
✓ Branch 1 taken 158174 times.
316790 if(clk&4)
9158 {
9159 158174 tile+=1;
9160 158174 }
9161
9162
2/4
✓ Branch 0 taken 316790 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 316790 times.
316790 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
9163 {
9164
2/2
✓ Branch 0 taken 283104 times.
✓ Branch 1 taken 33686 times.
316790 if(dummy_int[1]>0)
9165 {
9166 33686 tile+=40;
9167 33686 }
9168 316790 }
9169 316790 }
9170 else
9171 {
9172
4/4
✓ Branch 0 taken 255725 times.
✓ Branch 1 taken 23219 times.
✓ Branch 2 taken 59829 times.
✓ Branch 3 taken 195896 times.
278944 if(dummy_bool[1]||dummy_bool[2])
9173 {
9174 83048 tile+=20;
9175
9176
2/2
✓ Branch 0 taken 23219 times.
✓ Branch 1 taken 59829 times.
83048 if(dummy_bool[2])
9177 {
9178 59829 tile+=20;
9179 59829 }
9180 83048 }
9181
9182 278944 tile+=((frame>>1)&3);
9183 }
9184 }
9185 595734 break;
9186
9187 case a3FRM:
9188 {
9189
2/2
✓ Branch 0 taken 36161 times.
✓ Branch 1 taken 115353 times.
151514 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
9190 }
9191 151514 break;
9192
9193 case a3FRM4DIR:
9194 {
9195 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
9196 }
9197 break;
9198
9199 case aVIRE:
9200 {
9201
2/2
✓ Branch 0 taken 56929 times.
✓ Branch 1 taken 17916 times.
74845 if(dir==up)
9202 {
9203 17916 tile+=2;
9204 17916 }
9205
9206 74845 tile+=fx;
9207 }
9208 74845 break;
9209
9210 case aROPE:
9211 {
9212 117019 tile+=(1-fx);
9213 117019 flip = dir==left ? 1:0;
9214 }
9215 117019 break;
9216
9217 case aZORA:
9218 {
9219 int32_t dl;
9220
9221
2/2
✓ Branch 0 taken 29838 times.
✓ Branch 1 taken 113451 times.
143289 if(clk<36)
9222 {
9223 29838 dl=clk+5;
9224 29838 goto waves2;
9225 }
9226
9227
2/2
✓ Branch 0 taken 53267 times.
✓ Branch 1 taken 60184 times.
113451 if(clk<36+66)
9228
2/2
✓ Branch 0 taken 30913 times.
✓ Branch 1 taken 22354 times.
53267 tile=(dir==up)?o_tile+1:o_tile;
9229 else
9230 {
9231 60184 dl=clk-36-66;
9232 waves2:
9233 90022 tile=((dl/11)&1)+s_tile;
9234 90022 basetile = s_tile;
9235 }
9236 }
9237 143289 break;
9238
9239 case aNEWZORA:
9240 {
9241 401570 f4=(clk/16)%4;
9242
9243 401570 tiledir(dir,true);
9244 int32_t dl;
9245
9246
4/4
✓ Branch 0 taken 289179 times.
✓ Branch 1 taken 112391 times.
✓ Branch 2 taken 151547 times.
✓ Branch 3 taken 137632 times.
401570 if((clk>35)&&(clk<36+67)) //surfaced
9247 {
9248
4/4
✓ Branch 0 taken 117577 times.
✓ Branch 1 taken 20055 times.
✓ Branch 2 taken 16796 times.
✓ Branch 3 taken 100781 times.
137632 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
9249 {
9250 100781 tile+=80;
9251 100781 } //mouth closed
9252 else
9253 {
9254 36851 tile+=40;
9255 }
9256
9257 137632 tile+=f4;
9258 137632 }
9259 else
9260 {
9261
2/2
✓ Branch 0 taken 112391 times.
✓ Branch 1 taken 151547 times.
263938 if(clk<36)
9262 {
9263 112391 dl=clk+5;
9264 112391 }
9265 else
9266 {
9267 151547 dl=clk-36-66;
9268 }
9269
9270 263938 tile+=((dl/5)&3);
9271 }
9272 }
9273 401570 break;
9274
9275 case a4FRM4EYE:
9276 case a2FRM4EYE:
9277 case a4FRM8EYE:
9278 case a4FRM8EYEB: //big version
9279 case a4FRM4EYEB:
9280 {
9281 125758 tilerows = 2;
9282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125758 times.
125758 int fakex = x + 8*(zc_max(1,txsz)-1);
9283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125758 times.
125758 int fakey = y + 8*(zc_max(1,tysz)-1);
9284 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9285 125758 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
9286 125758 int32_t lookat=zc_oldrand()&15;
9287
9288
4/4
✓ Branch 0 taken 40954 times.
✓ Branch 1 taken 84804 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 20770 times.
125758 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
9289 {
9290 20770 lookat=l_down;
9291 20770 }
9292
4/4
✓ Branch 0 taken 41154 times.
✓ Branch 1 taken 63834 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 20970 times.
104988 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
9293 {
9294 20970 lookat=down;
9295 20970 }
9296
4/4
✓ Branch 0 taken 33302 times.
✓ Branch 1 taken 50716 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 13118 times.
84018 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
9297 {
9298 13118 lookat=r_down;
9299 13118 }
9300
4/4
✓ Branch 0 taken 31638 times.
✓ Branch 1 taken 39262 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 11454 times.
70900 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
9301 {
9302 11454 lookat=right;
9303 11454 }
9304
4/4
✓ Branch 0 taken 24538 times.
✓ Branch 1 taken 34908 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 4354 times.
59446 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
9305 {
9306 4354 lookat=r_up;
9307 4354 }
9308
4/4
✓ Branch 0 taken 25602 times.
✓ Branch 1 taken 29490 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 5418 times.
55092 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
9309 {
9310 5418 lookat=up;
9311 5418 }
9312
4/4
✓ Branch 0 taken 29766 times.
✓ Branch 1 taken 19908 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 9582 times.
49674 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
9313 {
9314 9582 lookat=l_up;
9315 9582 }
9316 else
9317 {
9318 40092 lookat=left;
9319 }
9320
9321 125758 int32_t dir2 = dir;
9322 125758 dir = lookat;
9323
3/6
✓ Branch 0 taken 125758 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125758 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 125758 times.
125758 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
9324 else
9325 {
9326 tiledir_big(dir,(anim == a4FRM4EYEB));
9327 tile+=2*f4;
9328 ignore_extend = true;
9329 }
9330 125758 dir = dir2;
9331 }
9332 125758 break;
9333
9334 case aFLIP:
9335 {
9336 918246 flip = f2&1;
9337 }
9338 918246 break;
9339
9340 case a2FRM:
9341 {
9342 706352 tile += (1-f2);
9343 }
9344 706352 break;
9345
9346 case a2FRMB:
9347 {
9348 tile+= 2*(1-f2);
9349 ignore_extend = true;
9350 }
9351 break;
9352
9353 case a2FRM4DIR:
9354 {
9355 77420 basetile = n_frame_n_dir(2, 4, f2&1);
9356 }
9357 77420 break;
9358
9359 case a4FRM4DIRF:
9360 {
9361 1902072 basetile = n_frame_n_dir(4,4,f4);
9362
9363
2/2
✓ Branch 0 taken 1210498 times.
✓ Branch 1 taken 691574 times.
1902072 if(clk2>0) //stopped to fire
9364 {
9365 691574 tile+=20;
9366
9367
2/2
✓ Branch 0 taken 328836 times.
✓ Branch 1 taken 362738 times.
691574 if(clk2<17) //firing
9368 {
9369 362738 tile+=20;
9370 362738 }
9371 691574 }
9372 }
9373 1902072 break;
9374
9375 case a4FRM4DIR:
9376 {
9377 3427398 basetile = n_frame_n_dir(4,4,f4);
9378 }
9379 3427398 break;
9380
9381 case a4FRM8DIRF:
9382 {
9383 tilerows = 2;
9384 basetile = n_frame_n_dir(4,8,f4);
9385
9386 if(clk2>0) //stopped to fire
9387 {
9388 tile+=40;
9389
9390 if(clk2<17) //firing
9391 {
9392 tile+=40;
9393 }
9394 }
9395 }
9396 break;
9397
9398 case a4FRM8DIRB:
9399 case a4FRM8DIRFB:
9400 {
9401 3868 tilerows = 2;
9402 3868 tiledir_big(dir,false);
9403 3868 tile+=2*f4;
9404
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
9405 {
9406 tile+=80;
9407
9408 if(clk2<17) //firing
9409 {
9410 tile+=80;
9411 }
9412 }
9413 3868 ignore_extend = true;
9414 }
9415 3868 break;
9416
9417 case a4FRM4DIRB:
9418 case a4FRM4DIRFB:
9419 {
9420 tilerows = 2;
9421 tiledir_big(dir,true);
9422 tile+=2*f4;
9423 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
9424 {
9425 tile+=40;
9426
9427 if(clk2<17) //firing
9428 {
9429 tile+=40;
9430 }
9431 }
9432 ignore_extend = true;
9433 }
9434 break;
9435
9436 case aOCTO:
9437 {
9438
5/5
✓ Branch 0 taken 1262 times.
✓ Branch 1 taken 72078 times.
✓ Branch 2 taken 83604 times.
✓ Branch 3 taken 100122 times.
✓ Branch 4 taken 88972 times.
346038 switch(dir)
9439 {
9440 case up:
9441 72078 flip = 2;
9442 72078 break;
9443
9444 case down:
9445 83604 flip = 0;
9446 83604 break;
9447
9448 case left:
9449 100122 flip = 0;
9450 100122 tile += 2;
9451 100122 break;
9452
9453 case right:
9454 88972 flip = 1;
9455 88972 tile += 2;
9456 88972 break;
9457 }
9458
9459 346038 tile+=f2;
9460 }
9461 346038 break;
9462
9463 case aWALK:
9464 {
9465
5/5
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 137564 times.
✓ Branch 2 taken 151741 times.
✓ Branch 3 taken 194033 times.
✓ Branch 4 taken 192706 times.
676948 switch(dir)
9466 {
9467 case up:
9468 137564 tile+=3;
9469 137564 flip = f2;
9470 137564 break;
9471
9472 case down:
9473 151741 tile+=2;
9474 151741 flip = f2;
9475 151741 break;
9476
9477 case left:
9478 194033 flip=1;
9479 194033 tile += f2;
9480 194033 break;
9481
9482 case right:
9483 192706 flip=0;
9484 192706 tile += f2;
9485 192706 break;
9486 }
9487 }
9488 676948 break;
9489
9490 case aDWALK:
9491 {
9492
3/4
✓ Branch 0 taken 81208 times.
✓ Branch 1 taken 442753 times.
✓ Branch 2 taken 81208 times.
✗ Branch 3 not taken.
523961 if((get_bit(quest_rules,qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
9493 {
9494 tile=s_tile;
9495 basetile = s_tile;
9496 }
9497
9498
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 108186 times.
✓ Branch 2 taken 113248 times.
✓ Branch 3 taken 152010 times.
✓ Branch 4 taken 150517 times.
523961 switch(dir)
9499 {
9500 case up:
9501 108186 tile+=2;
9502 108186 flip=f2;
9503 108186 break;
9504
9505 case down:
9506 113248 flip=0;
9507 113248 tile+=(1-f2);
9508 113248 break;
9509
9510 case left:
9511 152010 flip=1;
9512 152010 tile+=(3+f2);
9513 152010 break;
9514
9515 case right:
9516 150517 flip=0;
9517 150517 tile+=(3+f2);
9518 150517 break;
9519 }
9520 }
9521 523961 break;
9522
9523 case aTEK:
9524 {
9525
2/2
✓ Branch 0 taken 83152 times.
✓ Branch 1 taken 45021 times.
128173 if(misc==0)
9526 {
9527 45021 tile += f2;
9528 45021 }
9529
2/2
✓ Branch 0 taken 43837 times.
✓ Branch 1 taken 39315 times.
83152 else if(misc!=1)
9530 {
9531 39315 ++tile;
9532 39315 }
9533 }
9534 128173 break;
9535
9536 case aNEWTEK:
9537 {
9538
2/2
✓ Branch 0 taken 300104 times.
✓ Branch 1 taken 892438 times.
1192542 if(step<0) //up
9539 {
9540
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 147182 times.
✓ Branch 2 taken 152922 times.
300104 switch(clk3)
9541 {
9542 case left:
9543 147182 flip=0;
9544 147182 tile+=20;
9545 147182 break;
9546
9547 case right:
9548 152922 flip=0;
9549 152922 tile+=24;
9550 152922 break;
9551 }
9552 300104 }
9553
2/2
✓ Branch 0 taken 38135 times.
✓ Branch 1 taken 854303 times.
892438 else if(step==0)
9554 {
9555
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 28780 times.
✓ Branch 2 taken 9355 times.
38135 switch(clk3)
9556 {
9557 case left:
9558 28780 flip=0;
9559 28780 tile+=8;
9560 28780 break;
9561
9562 case right:
9563 9355 flip=0;
9564 9355 tile+=12;
9565 9355 break;
9566 }
9567 38135 } //down
9568 else
9569 {
9570
3/3
✓ Branch 0 taken 55883 times.
✓ Branch 1 taken 403679 times.
✓ Branch 2 taken 394741 times.
854303 switch(clk3)
9571 {
9572 case left:
9573 403679 flip=0;
9574 403679 tile+=28;
9575 403679 break;
9576
9577 case right:
9578 394741 flip=0;
9579 394741 tile+=32;
9580 394741 break;
9581 }
9582 }
9583
9584
2/2
✓ Branch 0 taken 757764 times.
✓ Branch 1 taken 434778 times.
1192542 if(misc==0)
9585 {
9586 434778 tile+=f4;
9587 434778 }
9588
2/2
✓ Branch 0 taken 367826 times.
✓ Branch 1 taken 389938 times.
757764 else if(misc!=1)
9589 {
9590 389938 tile+=2;
9591 389938 }
9592 }
9593 1192542 break;
9594
9595 case aARMOS:
9596 {
9597
2/2
✓ Branch 0 taken 2153 times.
✓ Branch 1 taken 3306 times.
5459 if(!fading)
9598 {
9599 3306 tile += fx;
9600
9601
2/2
✓ Branch 0 taken 2459 times.
✓ Branch 1 taken 847 times.
3306 if(dir==up)
9602 847 tile += 2;
9603 3306 }
9604 }
9605 5459 break;
9606
9607 case aARMOS4:
9608 {
9609
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5907 times.
✓ Branch 2 taken 12136 times.
✓ Branch 3 taken 8764 times.
✓ Branch 4 taken 8745 times.
35552 switch(dir)
9610 {
9611 case up:
9612 5907 flip=0;
9613 5907 break;
9614
9615 case down:
9616 12136 flip=0;
9617 12136 tile+=4;
9618 12136 break;
9619
9620 case left:
9621 8764 flip=0;
9622 8764 tile+=8;
9623 8764 break;
9624
9625 case right:
9626 8745 flip=0;
9627 8745 tile+=12;
9628 8745 break;
9629 }
9630
9631
2/2
✓ Branch 0 taken 6441 times.
✓ Branch 1 taken 29111 times.
35552 if(!fading)
9632 {
9633 29111 tile+=f4;
9634 29111 }
9635 }
9636 35552 break;
9637
9638 case aGHINI:
9639 {
9640
4/4
✓ Branch 0 taken 14879 times.
✓ Branch 1 taken 18684 times.
✓ Branch 2 taken 39994 times.
✓ Branch 3 taken 374 times.
73931 switch(dir)
9641 {
9642 case 8:
9643 case 9:
9644 case up:
9645 14879 ++tile;
9646 14879 flip=0;
9647 14879 break;
9648
9649 case 15:
9650 374 ++tile;
9651 374 flip=1;
9652 374 break;
9653
9654 case 10:
9655 case 11:
9656 case right:
9657 18684 flip=1;
9658 18684 break;
9659
9660 default:
9661 39994 flip=0;
9662 39994 break;
9663 }
9664 }
9665 73931 break;
9666
9667 case a2FRMPOS:
9668 {
9669 1156612 tile+=posframe;
9670 }
9671 1156612 break;
9672
9673 case a4FRMPOS4DIR:
9674 {
9675 216057 basetile = n_frame_n_dir(4,4,0);
9676 // tile+=f2;
9677 216057 tile+=posframe;
9678 }
9679 216057 break;
9680
9681 case a4FRMPOS4DIRF:
9682 {
9683 basetile = n_frame_n_dir(4,4,0);
9684
9685 if(clk2>0) //stopped to fire
9686 {
9687 tile+=20;
9688
9689 if(clk2<17) //firing
9690 {
9691 tile+=20;
9692 }
9693 }
9694
9695 // tile+=f2;
9696 tile+=posframe;
9697 }
9698 break;
9699
9700 case a4FRMPOS8DIR:
9701 {
9702 3146848 tilerows = 2;
9703 3146848 int32_t n = tile;
9704 3146848 basetile = n_frame_n_dir(4,8,0);
9705 // tile+=f2;
9706 3146848 tile+=posframe;
9707 }
9708 3146848 break;
9709
9710 case a4FRMPOS8DIRF:
9711 {
9712 tilerows = 2;
9713 basetile = n_frame_n_dir(4,8,0);
9714
9715 if(clk2>0) //stopped to fire
9716 {
9717 tile+=40;
9718
9719 if(clk2<17) //firing
9720 {
9721 tile+=40;
9722 }
9723 }
9724
9725 tile+=posframe;
9726 }
9727 break;
9728
9729 case aNEWLEV:
9730 {
9731 281552 tiledir(dir,true);
9732
9733
4/5
✓ Branch 0 taken 92775 times.
✓ Branch 1 taken 45501 times.
✓ Branch 2 taken 18315 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124961 times.
281552 switch(misc)
9734 {
9735 case -1:
9736 case 0:
9737 92775 return;
9738
9739 case 1:
9740
9741 // case 5: cs = d->misc2; break;
9742 case 5:
9743 45501 cs = dmisc2;
9744 45501 break;
9745
9746 case 2:
9747 case 4:
9748 18315 tile += 20;
9749 18315 break;
9750
9751 case 3:
9752 124961 tile += 40;
9753 124961 break;
9754 }
9755
9756 188777 tile+=f4;
9757 }
9758 188777 break;
9759
9760 case aLEV:
9761 {
9762 156657 f4 = ((clk/5)&1);
9763
9764
4/5
✓ Branch 0 taken 86920 times.
✓ Branch 1 taken 15858 times.
✓ Branch 2 taken 7271 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46608 times.
156657 switch(misc)
9765 {
9766 case -1:
9767 case 0:
9768 86920 return;
9769
9770 case 1:
9771
9772 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
9773 case 5:
9774 15858 tile += (f2) ? 1 : 0;
9775 15858 cs = dmisc2;
9776 15858 break;
9777
9778 case 2:
9779 case 4:
9780 7271 tile += 2;
9781 7271 break;
9782
9783 case 3:
9784 46608 tile += (f4) ? 4 : 3;
9785 46608 break;
9786 }
9787 }
9788 69737 break;
9789
9790 case aWALLM:
9791 {
9792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86767 times.
86767 if(!dummy_bool[1])
9793 {
9794 86767 tile += f2;
9795 86767 }
9796 }
9797 86767 break;
9798
9799 case aNEWWALLM:
9800 {
9801 207174 int32_t tempdir=0;
9802
9803
4/4
✓ Branch 0 taken 27129 times.
✓ Branch 1 taken 20687 times.
✓ Branch 2 taken 5822 times.
✓ Branch 3 taken 153536 times.
207174 switch(misc)
9804 {
9805 case 1:
9806 case 2:
9807 20687 tempdir=clk3;
9808 20687 break;
9809
9810 case 3:
9811 case 4:
9812 case 5:
9813 27129 tempdir=dir;
9814 27129 break;
9815
9816 case 6:
9817 case 7:
9818 5822 tempdir=clk3^1;
9819 5822 break;
9820 }
9821
9822 207174 tiledir(tempdir,true);
9823
9824
2/2
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 206596 times.
207174 if(!dummy_bool[1])
9825 {
9826 206596 tile+=f4;
9827 206596 }
9828 }
9829 207174 break;
9830
9831 case a4FRMNODIR:
9832 {
9833 36233 tile+=f4;
9834 }
9835 36233 break;
9836
9837 } // switch(d->anim)
9838
9839 // flashing
9840 // if(d->flags2 & guy_flashing)
9841
2/2
✓ Branch 0 taken 18890909 times.
✓ Branch 1 taken 477196 times.
19368105 if(flags2 & guy_flashing)
9842 {
9843 477196 cs = (frame&3) + 6;
9844 477196 }
9845
9846
2/2
✓ Branch 0 taken 19335991 times.
✓ Branch 1 taken 32114 times.
19368105 if(flags2&guy_transparent)
9847 {
9848 32114 drawstyle=1;
9849 32114 }
9850
9851 19368105 int32_t change = tile-basetile;
9852
9853
3/6
✓ Branch 0 taken 374939 times.
✓ Branch 1 taken 18993166 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 374939 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
19368105 if(extend > 2 && (!ignore_extend || get_bit(quest_rules, qr_BROKEN_BIG_ENEMY_ANIMATION)))
9854 {
9855
2/2
✓ Branch 0 taken 374526 times.
✓ Branch 1 taken 413 times.
374939 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
9856 {
9857 374526 tile=basetile+txsz*change;
9858 374526 }
9859 else
9860 {
9861 413 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
9862 }
9863 374939 }
9864 else
9865 {
9866 18993166 tile=basetile+change;
9867 }
9868 19547942 }
9869
9870 49448 int32_t wpnsfx(int32_t wpn)
9871 {
9872
5/6
✓ Branch 0 taken 17448 times.
✓ Branch 1 taken 238 times.
✓ Branch 2 taken 17188 times.
✓ Branch 3 taken 9271 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5303 times.
49448 switch(wpn)
9873 {
9874 case ewFireTrail:
9875 case ewFlame:
9876 case ewFlame2Trail:
9877 case ewFlame2:
9878 17448 return WAV_FIRE;
9879
9880 case ewWind:
9881 case ewMagic:
9882 238 return WAV_WAND;
9883
9884 case ewIce:
9885 return WAV_ZN1ICE;
9886
9887 case ewRock:
9888
2/2
✓ Branch 0 taken 5039 times.
✓ Branch 1 taken 264 times.
5303 if(get_bit(quest_rules,qr_MORESOUNDS)) return WAV_ZN1ROCK;
9889 5039 break;
9890
9891 case ewFireball2:
9892 case ewFireball:
9893
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 17181 times.
17188 if(get_bit(quest_rules,qr_MORESOUNDS)) return WAV_ZN1FIREBALL;
9894 17181 }
9895
9896 31491 return -1;
9897 49448 }
9898
9899 36319391 int32_t enemy::run_script(int32_t mode)
9900 {
9901
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36319391 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36319391 if(switch_hooked && !get_bit(quest_rules, qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
9902
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 36319391 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
36319391 if (script <= 0 || !doscript || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
9903 36319391 return RUNSCRIPT_OK;
9904 int32_t ret = RUNSCRIPT_OK;
9905 alloc_scriptmem();
9906 switch(mode)
9907 {
9908 case MODE_NORMAL:
9909 return ZScriptVersion::RunScript(SCRIPT_NPC, script, getUID());
9910 case MODE_WAITDRAW:
9911 if(waitdraw)
9912 {
9913 ret = ZScriptVersion::RunScript(SCRIPT_NPC, script, getUID());
9914 waitdraw = 0;
9915 }
9916 break;
9917 }
9918 return ret;
9919 36319391 }
9920 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
9921 {
9922 return al_map_rgba(255,0,0,opacity);
9923 }
9924 /********************************/
9925 /********* Guy Class **********/
9926 /********************************/
9927
9928 // good guys, fires, fairy, and other non-enemies
9929 // based on enemy class b/c guys in dungeons act sort of like enemies
9930 // also easier to manage all the guys this way
9931 2402 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
9932 2402 {
9933 1201 mainguy=mg;
9934 1201 canfreeze=false;
9935 1201 dir=down;
9936
3/6
✓ Branch 0 taken 1201 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1201 times.
✓ Branch 4 taken 1201 times.
✗ Branch 5 not taken.
1201 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9937 1201 hxofs=2;
9938 1201 hzsz=8;
9939 1201 hxsz=12;
9940 1201 hysz=17;
9941
9942
10/12
✓ Branch 0 taken 1201 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1201 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 387 times.
✓ Branch 5 taken 814 times.
✓ Branch 6 taken 377 times.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 142 times.
✓ Branch 9 taken 235 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 130 times.
1201 if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA))
9943 {
9944 1071 superman = 1;
9945 1071 hxofs=1000;
9946 1071 }
9947 1201 }
9948
9949 434800 bool guy::animate(int32_t index)
9950 {
9951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434800 times.
434800 if(switch_hooked) return enemy::animate(index);
9952
6/6
✓ Branch 0 taken 177047 times.
✓ Branch 1 taken 257753 times.
✓ Branch 2 taken 1678 times.
✓ Branch 3 taken 175369 times.
✓ Branch 4 taken 1140 times.
✓ Branch 5 taken 538 times.
434800 if(mainguy && clk==0 && misc==0)
9953 {
9954 538 setupscreen();
9955 538 misc = 1;
9956 538 }
9957
9958
4/4
✓ Branch 0 taken 177047 times.
✓ Branch 1 taken 257753 times.
✓ Branch 2 taken 176871 times.
✓ Branch 3 taken 176 times.
434800 if(mainguy && fadeclk==0)
9959 176 return true;
9960
9961 434624 hp=256; // good guys never die...
9962
9963
4/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 434540 times.
✓ Branch 2 taken 81 times.
✓ Branch 3 taken 3 times.
434624 if(hclk && !clk2)
9964 {
9965 // but if they get hit...
9966 3 ++clk2; // only do this once
9967
9968
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(!get_bit(quest_rules,qr_NOGUYFIRES))
9969 {
9970 1 addenemy(BSZ?64:72,68,eSHOOTFBALL,0);
9971 1 addenemy(BSZ?176:168,68,eSHOOTFBALL,0);
9972 1 }
9973 3 }
9974
9975 434624 return enemy::animate(index);
9976 434800 }
9977
9978 437206 void guy::draw(BITMAP *dest)
9979 {
9980 437206 update_enemy_frame();
9981
9982
6/6
✓ Branch 0 taken 179323 times.
✓ Branch 1 taken 257883 times.
✓ Branch 2 taken 11867 times.
✓ Branch 3 taken 167456 times.
✓ Branch 4 taken 5932 times.
✓ Branch 5 taken 5935 times.
437206 if(!mainguy || fadeclk<0 || fadeclk&1)
9983 431271 enemy::draw(dest);
9984 437206 }
9985
9986 /*******************************/
9987 /********* Enemies *********/
9988 /*******************************/
9989
9990 158 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9991 158 {
9992 79 clk4=0;
9993 79 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
9994 // Spawn type
9995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(flags & guy_fadeflicker)
9996 {
9997 clk=0;
9998 superman = 1;
9999 fading=fade_flicker;
10000 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10001 dir=down;
10002
10003 if(!canmove(down,(zfix)8,spw_none,false))
10004 clk3=int32_t(13.0/step);
10005 }
10006
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 else if(flags & guy_fadeinstant)
10007 {
10008 clk=0;
10009 }
10010 79 SIZEflags = d->SIZEflags;
10011
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
79 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10012 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10013 // al_trace("Enemy txsz:%i\n", txsz);
10014
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
79 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10015
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
79 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10016
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
79 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10017
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
79 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10018
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10019
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10020 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10021
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
79 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10023 {
10024 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10025 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10026 }
10027
10028
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
79 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) d->zofs = (int32_t)zofs;
10029 79 }
10030
10031 40167 bool eFire::animate(int32_t index)
10032 {
10033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40167 times.
40167 if(switch_hooked) return enemy::animate(index);
10034
2/4
✓ Branch 0 taken 40167 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 40167 times.
40167 if(fallclk||drownclk) return enemy::animate(index);
10035
2/2
✓ Branch 0 taken 39863 times.
✓ Branch 1 taken 304 times.
40167 if(fading)
10036 {
10037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 if(++clk4 > 60)
10038 {
10039 clk4=0;
10040 superman=0;
10041 fading=0;
10042
10043 if(flags2&cmbflag_armos && z==0 && fakez==0)
10044 removearmos(x,y,ffcactivated);
10045
10046 clk2=0;
10047
10048 if(!canmove(down,(zfix)8,spw_none,false))
10049 {
10050 dir=0;
10051 y = y.getInt() & 0xF0;
10052 }
10053
10054 return Dead(index);
10055 }
10056
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
304 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10057 removearmos(x,y,ffcactivated);
10058 304 }
10059
10060 40167 return enemy::animate(index);
10061 40167 }
10062
10063 83508 void eFire::draw(BITMAP *dest)
10064 {
10065 83508 update_enemy_frame();
10066 83508 enemy::draw(dest);
10067 83508 }
10068
10069 101 int32_t eFire::takehit(weapon *w, weapon* realweap)
10070 {
10071 101 int32_t wpnId = w->id;
10072 101 int32_t wpnDir = w->dir;
10073
10074
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
101 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10075 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10076 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10077 {
10078 shield = false;
10079 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10080
10081 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10082 o_tile=s_tile;
10083 }
10084
10085 101 int32_t ret = enemy::takehit(w,realweap);
10086 101 return ret;
10087 }
10088
10089 void eFire::break_shield()
10090 {
10091 if(!shield)
10092 return;
10093
10094 flags&=~(inv_front | inv_back | inv_left | inv_right);
10095 shield=false;
10096
10097 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10098 o_tile=s_tile;
10099 }
10100
10101 2556 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10102 2556 {
10103 //zprint2("npct other::other\n");
10104 1278 clk4=0;
10105 1278 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10106
10107 // Spawn type
10108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
1278 if(flags & guy_fadeflicker)
10109 {
10110 clk=0;
10111 superman = 1;
10112 fading=fade_flicker;
10113 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10114 dir=down;
10115
10116 if(!canmove(down,(zfix)8,spw_none,false))
10117 clk3=int32_t(13.0/step);
10118 }
10119
1/2
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
1278 else if(flags & guy_fadeinstant)
10120 {
10121 clk=0;
10122 }
10123 1278 SIZEflags = d->SIZEflags;
10124
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1278 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10125 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10126 // al_trace("Enemy txsz:%i\n", txsz);
10127
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1278 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10128
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1278 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10129
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1278 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10130
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1278 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10131
1/2
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
1278 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10132
1/2
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
1278 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10133 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10134
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1278 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
1278 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10136 {
10137 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10138 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10139 }
10140
10141
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1278 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10142 1278 }
10143
10144 380627 bool eOther::animate(int32_t index)
10145 {
10146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 380627 times.
380627 if(switch_hooked) return enemy::animate(index);
10147
2/4
✓ Branch 0 taken 380627 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 380627 times.
380627 if(fallclk||drownclk) return enemy::animate(index);
10148 //zprint2("npct other::animate\n");
10149
1/2
✓ Branch 0 taken 380627 times.
✗ Branch 1 not taken.
380627 if(fading)
10150 {
10151 if(++clk4 > 60)
10152 {
10153 clk4=0;
10154 superman=0;
10155 fading=0;
10156
10157 if(flags2&cmbflag_armos && z==0 && fakez==0)
10158 removearmos(x,y,ffcactivated);
10159
10160 clk2=0;
10161
10162 if(!canmove(down,(zfix)8,spw_none,false))
10163 {
10164 dir=0;
10165 y = y.getInt() & 0xF0;
10166 }
10167
10168 return Dead(index);
10169 }
10170 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10171 removearmos(x,y,ffcactivated);
10172 }
10173
10174 380627 return enemy::animate(index);
10175 380627 }
10176
10177 398420 void eOther::draw(BITMAP *dest)
10178 {
10179 398420 update_enemy_frame();
10180 398420 enemy::draw(dest);
10181 398420 }
10182
10183 2767 int32_t eOther::takehit(weapon *w, weapon* realweap)
10184 {
10185 2767 int32_t wpnId = w->id;
10186 2767 int32_t wpnDir = w->dir;
10187
10188
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 2750 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
2767 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10189 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10190 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10191 {
10192 shield = false;
10193 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10194
10195 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10196 o_tile=s_tile;
10197 }
10198
10199 2767 int32_t ret = enemy::takehit(w,realweap);
10200 2767 return ret;
10201 }
10202
10203 void eOther::break_shield()
10204 {
10205 if(!shield)
10206 return;
10207
10208 flags&=~(inv_front | inv_back | inv_left | inv_right);
10209 shield=false;
10210
10211 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10212 o_tile=s_tile;
10213 }
10214
10215
10216 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10217 {
10218 clk4=0;
10219 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10220
10221 // Spawn type
10222 if(flags & guy_fadeflicker)
10223 {
10224 clk=0;
10225 superman = 1;
10226 fading=fade_flicker;
10227 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10228 dir=down;
10229
10230 if(!canmove(down,(zfix)8,spw_none,false))
10231 clk3=int32_t(13.0/step);
10232 }
10233 else if(flags & guy_fadeinstant)
10234 {
10235 clk=0;
10236 }
10237 SIZEflags = d->SIZEflags;
10238 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10239 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10240 // al_trace("Enemy txsz:%i\n", txsz);
10241 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10242 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10243 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10244 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10245 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10246 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10247 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10248 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10249 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10250 {
10251 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10252 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10253 }
10254
10255 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10256 }
10257
10258 bool eScript::animate(int32_t index)
10259 {
10260 if(switch_hooked) return enemy::animate(index);
10261 if(fallclk||drownclk) return enemy::animate(index);
10262 if(fading)
10263 {
10264 if(++clk4 > 60)
10265 {
10266 clk4=0;
10267 superman=0;
10268 fading=0;
10269
10270 if(flags2&cmbflag_armos && z==0 && fakez==0)
10271 removearmos(x,y,ffcactivated);
10272
10273 clk2=0;
10274
10275 if(!canmove(down,(zfix)8,spw_none,false))
10276 {
10277 dir=0;
10278 y = y.getInt() & 0xF0;
10279 }
10280
10281 return Dead(index);
10282 }
10283 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10284 removearmos(x,y,ffcactivated);
10285 }
10286
10287 return enemy::animate(index);
10288 }
10289
10290 void eScript::draw(BITMAP *dest)
10291 {
10292 update_enemy_frame();
10293 enemy::draw(dest);
10294 }
10295
10296 int32_t eScript::takehit(weapon *w, weapon* realweap)
10297 {
10298 int32_t wpnId = w->id;
10299 int32_t wpnDir = w->dir;
10300
10301 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10302 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10303 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10304 {
10305 shield = false;
10306 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10307
10308 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10309 o_tile=s_tile;
10310 }
10311
10312 int32_t ret = enemy::takehit(w,realweap);
10313 return ret;
10314 }
10315
10316 void eScript::break_shield()
10317 {
10318 if(!shield)
10319 return;
10320
10321 flags&=~(inv_front | inv_back | inv_left | inv_right);
10322 shield=false;
10323
10324 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10325 o_tile=s_tile;
10326 }
10327
10328
10329 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10330 {
10331 clk4=0;
10332 hyofs = -32768; //No hitbox initially.
10333 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10334
10335 // Spawn type
10336 if(flags & guy_fadeflicker)
10337 {
10338 clk=0;
10339 superman = 1;
10340 fading=fade_flicker;
10341 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10342 dir=down;
10343
10344 if(!canmove(down,(zfix)8,spw_none,false))
10345 clk3=int32_t(13.0/step);
10346 }
10347 else if(flags & guy_fadeinstant)
10348 {
10349 clk=0;
10350 }
10351 SIZEflags = d->SIZEflags;
10352 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10353 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10354 // al_trace("Enemy txsz:%i\n", txsz);
10355 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10356 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10357 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10358 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10359 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10360 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10361 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10362 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10363 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10364 {
10365 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10366 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10367 }
10368
10369 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10370 }
10371
10372 bool eFriendly::animate(int32_t index)
10373 {
10374 if(switch_hooked) return enemy::animate(index);
10375 if(fallclk||drownclk) return enemy::animate(index);
10376 if(fading)
10377 {
10378 if(++clk4 > 60)
10379 {
10380 clk4=0;
10381 superman=0;
10382 fading=0;
10383
10384 if(flags2&cmbflag_armos && z==0 && fakez==0)
10385 removearmos(x,y,ffcactivated);
10386
10387 clk2=0;
10388
10389 if(!canmove(down,(zfix)8,spw_none,false))
10390 {
10391 dir=0;
10392 y = y.getInt() & 0xF0;
10393 }
10394
10395 return Dead(index);
10396 }
10397 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10398 removearmos(x,y,ffcactivated);
10399 }
10400
10401 return enemy::animate(index);
10402 }
10403
10404 void eFriendly::draw(BITMAP *dest)
10405 {
10406 update_enemy_frame();
10407 enemy::draw(dest);
10408 }
10409
10410 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
10411 {
10412 int32_t wpnId = w->id;
10413 int32_t wpnDir = w->dir;
10414
10415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10416 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10417 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10418 {
10419 shield = false;
10420 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10421
10422 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10423 o_tile=s_tile;
10424 }
10425
10426 int32_t ret = enemy::takehit(w,realweap);
10427 return ret;
10428 }
10429
10430 void eFriendly::break_shield()
10431 {
10432 if(!shield)
10433 return;
10434
10435 flags&=~(inv_front | inv_back | inv_left | inv_right);
10436 shield=false;
10437
10438 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10439 o_tile=s_tile;
10440 }
10441
10442
10443 313808 void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive)
10444 {
10445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 313808 times.
313808 if (ffcactive)
10446 {
10447 removearmosffc(ffcactive-1);
10448 return;
10449 }
10450
2/2
✓ Branch 0 taken 313176 times.
✓ Branch 1 taken 632 times.
313808 if(did_armos)
10451 {
10452 313176 return;
10453 }
10454
10455 632 did_armos=true;
10456 632 ax&=0xF0;
10457 632 ay&=0xF0;
10458 632 int32_t cd = (ax>>4)+ay;
10459 632 int32_t f = MAPFLAG(ax,ay);
10460 632 int32_t f2 = MAPCOMBOFLAG(ax,ay);
10461
10462
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 110 times.
632 if(combobuf[tmpscr->data[cd]].type!=cARMOS)
10463 {
10464 522 return;
10465 }
10466
10467 110 tmpscr->data[cd] = tmpscr->undercombo;
10468 110 tmpscr->cset[cd] = tmpscr->undercset;
10469 110 tmpscr->sflag[cd] = 0;
10470
10471
3/4
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
110 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
10472 {
10473 20 tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS];
10474 20 tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS];
10475 20 tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS];
10476 20 sfx(tmpscr->secretsfx);
10477 20 }
10478
10479
3/4
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
110 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
10480 {
10481
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if(!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
10482 {
10483 2 additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
10484 2 sfx(tmpscr->secretsfx);
10485 2 }
10486 2 }
10487
10488 110 putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]);
10489 313808 }
10490
10491 void enemy::removearmosffc(int32_t pos)
10492 {
10493 if(did_armos)
10494 {
10495 return;
10496 }
10497
10498 did_armos=true;
10499 ffcdata& ffc = tmpscr->ffcs[pos];
10500 newcombo const& cmb = combobuf[ffc.getData()];
10501 int32_t f2 = cmb.flag;
10502
10503 if(cmb.type!=cARMOS)
10504 {
10505 return;
10506 }
10507
10508 ffc.setData(tmpscr->undercombo);
10509 ffc.cset = tmpscr->undercset;
10510
10511 if(f2 == mfARMOS_SECRET)
10512 {
10513 ffc.setData(tmpscr->secretcombo[sSTAIRS]);
10514 ffc.cset = tmpscr->secretcset[sSTAIRS];
10515 sfx(tmpscr->secretsfx);
10516 }
10517
10518 if(f2 == mfARMOS_ITEM)
10519 {
10520 if(!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
10521 {
10522 additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
10523 sfx(tmpscr->secretsfx);
10524 }
10525 }
10526
10527 putcombo(scrollbuf,ffc.x,ffc.y,ffc.getData(),ffc.cset);
10528 }
10529
10530
10531 278 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10532 278 {
10533 139 fading=fade_flicker;
10534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10535 139 dir=12;
10536 139 movestatus=1;
10537
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 step=0;
10538 139 clk=0;
10539 139 clk4=0;
10540 139 SIZEflags = d->SIZEflags;
10541
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10542 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10543 // al_trace("Enemy txsz:%i\n", txsz);
10544
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10545
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10546
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10547
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10548
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10549
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10550 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10551
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10553 {
10554 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10555 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10556 }
10557
10558
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10559 139 }
10560
10561 50941 bool eGhini::animate(int32_t index)
10562 {
10563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50941 times.
50941 if(switch_hooked) return enemy::animate(index);
10564
2/4
✓ Branch 0 taken 50941 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50941 times.
50941 if(fallclk||drownclk) return enemy::animate(index);
10565
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 50905 times.
50941 if(dying)
10566 36 return Dead(index);
10567
10568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50905 times.
50905 if(dmisc1)
10569 {
10570
2/2
✓ Branch 0 taken 42559 times.
✓ Branch 1 taken 8346 times.
50905 if(misc)
10571 {
10572
2/2
✓ Branch 0 taken 11685 times.
✓ Branch 1 taken 30874 times.
42559 if(clk4>160)
10573 30874 misc=2;
10574
10575
2/2
✓ Branch 0 taken 11685 times.
✓ Branch 1 taken 30874 times.
42559 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
10576 42559 removearmos(x,y,ffcactivated);
10577 42559 }
10578
2/2
✓ Branch 0 taken 8212 times.
✓ Branch 1 taken 134 times.
8346 else if(clk4>=60)
10579 {
10580 134 misc=1;
10581 134 clk3=32;
10582 134 fading=0;
10583
1/2
✓ Branch 0 taken 134 times.
✗ Branch 1 not taken.
134 if (ffcactivated > 0)
10584 {
10585 guygridffc[ffcactivated-1] = 0;
10586 removearmosffc(ffcactivated-1);
10587 }
10588 else
10589 {
10590 134 guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0;
10591 134 removearmos(x,y);
10592 }
10593 134 }
10594 50905 }
10595
10596 50905 clk4++;
10597
10598 50905 return enemy::animate(index);
10599 50941 }
10600
10601 101940 void eGhini::draw(BITMAP *dest)
10602 {
10603 101940 update_enemy_frame();
10604 101940 enemy::draw(dest);
10605 101940 }
10606
10607 2 void eGhini::kickbucket()
10608 {
10609 2 hp=-1000; // don't call death_sfx()
10610 2 }
10611
10612
3/6
✓ Branch 0 taken 2264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2264 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2264 times.
✗ Branch 5 not taken.
6792 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10613 4528 {
10614
1/2
✓ Branch 0 taken 2264 times.
✗ Branch 1 not taken.
2264 old_y=y;
10615 2264 dir=down;
10616 2264 misc=1;
10617 2264 clk=-15;
10618
10619
2/2
✓ Branch 0 taken 2244 times.
✓ Branch 1 taken 20 times.
2264 if(!BSZ)
10620
1/2
✓ Branch 0 taken 2244 times.
✗ Branch 1 not taken.
2244 clk*=zc_oldrand()%3+1;
10621
10622 // avoid divide by 0 errors
10623
1/2
✓ Branch 0 taken 2264 times.
✗ Branch 1 not taken.
2264 if(dmisc1 == 0)
10624 dmisc1 = 24;
10625
10626
1/2
✓ Branch 0 taken 2264 times.
✗ Branch 1 not taken.
2264 if(dmisc2 == 0)
10627 dmisc2 = 3;
10628
10629 //nets+760;
10630 2264 SIZEflags = d->SIZEflags;
10631
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2264 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10632 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10633 // al_trace("Enemy txsz:%i\n", txsz);
10634
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2264 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10635
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2264 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10636
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2264 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10637
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2264 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10638
1/2
✓ Branch 0 taken 2264 times.
✗ Branch 1 not taken.
2264 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10639
1/2
✓ Branch 0 taken 2264 times.
✗ Branch 1 not taken.
2264 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10640 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10641
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2264 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2264 times.
2264 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10643 {
10644 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10645 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10646 }
10647
10648
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2264 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10649 2264 }
10650
10651 751184 bool eTektite::animate(int32_t index)
10652 {
10653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 751184 times.
751184 if(switch_hooked) return enemy::animate(index);
10654
4/4
✓ Branch 0 taken 746338 times.
✓ Branch 1 taken 4846 times.
✓ Branch 2 taken 4846 times.
✓ Branch 3 taken 751184 times.
751184 if(fallclk||drownclk) return enemy::animate(index);
10655
2/2
✓ Branch 0 taken 17103 times.
✓ Branch 1 taken 734081 times.
751184 if(dying)
10656 17103 return Dead(index);
10657
10658
2/2
✓ Branch 0 taken 715461 times.
✓ Branch 1 taken 18620 times.
734081 if(clk==0)
10659 {
10660 18620 removearmos(x,y,ffcactivated);
10661 18620 }
10662
10663
2/2
✓ Branch 0 taken 400947 times.
✓ Branch 1 taken 333134 times.
734081 if(get_bit(quest_rules,qr_ENEMIESZAXIS))
10664 {
10665 333134 y=floor_y;
10666 333134 }
10667
10668
9/10
✓ Branch 0 taken 661922 times.
✓ Branch 1 taken 72159 times.
✓ Branch 2 taken 657002 times.
✓ Branch 3 taken 4920 times.
✓ Branch 4 taken 657002 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10374 times.
✓ Branch 7 taken 646628 times.
✓ Branch 8 taken 4064 times.
✓ Branch 9 taken 9344 times.
734081 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
10669 {
10670
4/4
✓ Branch 0 taken 7880 times.
✓ Branch 1 taken 259402 times.
✓ Branch 2 taken 169848 times.
✓ Branch 3 taken 218842 times.
655972 switch(misc)
10671 {
10672 case 0: // normal
10673
2/2
✓ Branch 0 taken 253882 times.
✓ Branch 1 taken 5520 times.
259402 if(!(zc_oldrand()%dmisc1))
10674 {
10675 5520 misc=1;
10676 5520 clk2=32;
10677 5520 }
10678
10679 259402 break;
10680
10681 case 1: // waiting to pounce
10682
2/2
✓ Branch 0 taken 160892 times.
✓ Branch 1 taken 8956 times.
169848 if(--clk2<=0)
10683 {
10684 8956 int32_t r=zc_oldrand();
10685 8956 misc=2;
10686 8956 step=0-(zslongToFix(dstep*100)); // initial speed
10687 8956 clk3=(r&1)+2; // left or right
10688 8956 clk2start=clk2=(r&31)+10; // flight time
10689
10690
2/2
✓ Branch 0 taken 7814 times.
✓ Branch 1 taken 1142 times.
8956 if(y<32) clk2+=2; // make them come down from top of screen
10691
10692
2/2
✓ Branch 0 taken 6920 times.
✓ Branch 1 taken 2036 times.
8956 if(y>112) clk2-=2; // make them go back up
10693
10694 8956 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
10695 8956 }
10696
10697 169848 break;
10698
10699 case 2: // in flight
10700 218842 move(step);
10701
10702
2/2
✓ Branch 0 taken 105305 times.
✓ Branch 1 taken 113537 times.
218842 if(step>0) //going down
10703 {
10704
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 105149 times.
105305 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
10705 {
10706 156 step=0-step;
10707 156 }
10708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105149 times.
105149 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
10709 {
10710 step=0-step;
10711 }
10712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105149 times.
105149 else if(ispitfall(x+8,y+16))
10713 {
10714 step=0-step;
10715 }
10716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105149 times.
105149 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
10717 {
10718 step=0-step;
10719 }
10720
1/2
✓ Branch 0 taken 105149 times.
✗ Branch 1 not taken.
105149 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
10721 {
10722 step=0-step;
10723 }
10724 105305 }
10725
2/2
✓ Branch 0 taken 7302 times.
✓ Branch 1 taken 106235 times.
113537 else if(step<0)
10726 {
10727
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 106016 times.
106235 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
10728 {
10729 219 step=0-step;
10730 219 }
10731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106016 times.
106016 else if(COMBOTYPE(x+8,y)==cNOENEMY)
10732 {
10733 step=0-step;
10734 }
10735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106016 times.
106016 else if(ispitfall(x+8,y))
10736 {
10737 step=0-step;
10738 }
10739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106016 times.
106016 else if(MAPFLAG(x+8,y)==mfNOENEMY)
10740 {
10741 step=0-step;
10742 }
10743
1/2
✓ Branch 0 taken 106016 times.
✗ Branch 1 not taken.
106016 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
10744 {
10745 step=0-step;
10746 }
10747 106235 }
10748
10749
2/2
✓ Branch 0 taken 108800 times.
✓ Branch 1 taken 110042 times.
218842 if(clk3==left)
10750 {
10751
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 108699 times.
108800 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
10752 {
10753 101 clk3^=1;
10754 101 }
10755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108699 times.
108699 else if(COMBOTYPE(x,y+8)==cNOENEMY)
10756 {
10757 clk3^=1;
10758 }
10759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108699 times.
108699 else if(ispitfall(x,y+8))
10760 {
10761 clk3^=1;
10762 }
10763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108699 times.
108699 else if(MAPFLAG(x,y+8)==mfNOENEMY)
10764 {
10765 clk3^=1;
10766 }
10767
1/2
✓ Branch 0 taken 108699 times.
✗ Branch 1 not taken.
108699 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
10768 {
10769 clk3^=1;
10770 }
10771 108800 }
10772 else
10773 {
10774
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 109951 times.
110042 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
10775 {
10776 91 clk3^=1;
10777 91 }
10778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109951 times.
109951 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
10779 {
10780 clk3^=1;
10781 }
10782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109951 times.
109951 else if(ispitfall(x+16,y+8))
10783 {
10784 clk3^=1;
10785 }
10786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109951 times.
109951 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
10787 {
10788 clk3^=1;
10789 }
10790
1/2
✓ Branch 0 taken 109951 times.
✗ Branch 1 not taken.
109951 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
10791 {
10792 clk3^=1;
10793 }
10794 }
10795
10796 218842 --c;
10797
10798
4/4
✓ Branch 0 taken 66066 times.
✓ Branch 1 taken 152776 times.
✓ Branch 2 taken 143940 times.
✓ Branch 3 taken 74902 times.
218842 if(c<0 && step<zslongToFix(dstep*100))
10799 {
10800 74902 step+=zslongToFix(dmisc3*100);
10801 74902 }
10802
10803 218842 int32_t nb=get_bit(quest_rules,qr_NOBORDER) ? 16 : 0;
10804
10805
2/2
✓ Branch 0 taken 218601 times.
✓ Branch 1 taken 241 times.
218842 if(x<=16-nb) clk3=right;
10806
10807
2/2
✓ Branch 0 taken 218393 times.
✓ Branch 1 taken 449 times.
218842 if(x>=224+nb) clk3=left;
10808
10809 218842 x += (clk3==left) ? -1 : 1;
10810
10811
4/4
✓ Branch 0 taken 12383 times.
✓ Branch 1 taken 206459 times.
✓ Branch 2 taken 3940 times.
✓ Branch 3 taken 202519 times.
218842 if((--clk2<=0 && y>=16-nb) || y>=144+nb)
10812 {
10813
4/4
✓ Branch 0 taken 511 times.
✓ Branch 1 taken 7932 times.
✓ Branch 2 taken 334 times.
✓ Branch 3 taken 177 times.
16323 if(y>=144+nb && get_bit(quest_rules,qr_ENEMIESZAXIS))
10814 {
10815 177 step=0-step;
10816 177 y--;
10817 177 }
10818
2/2
✓ Branch 0 taken 6434 times.
✓ Branch 1 taken 1832 times.
8266 else if(zc_oldrand()%dmisc2) //land and wait
10819 {
10820 6434 clk=misc=0;
10821 6434 } //land and jump again
10822 else
10823 {
10824 1832 misc=1;
10825 1832 clk2=0;
10826 }
10827 8443 }
10828
10829 210962 break;
10830 } // switch
10831 648092 }
10832
10833
4/4
✓ Branch 0 taken 333134 times.
✓ Branch 1 taken 396101 times.
✓ Branch 2 taken 226451 times.
✓ Branch 3 taken 106683 times.
729235 if(get_bit(quest_rules,qr_ENEMIESZAXIS) && misc==2)
10834 {
10835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106683 times.
106683 if (moveflags & FLAG_USE_FAKE_Z)
10836 {
10837 int32_t tempy = floor_y;
10838 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
10839 floor_y = y;
10840 y=tempy-fakez;
10841 old_y = y;
10842 }
10843 else
10844 {
10845 106683 int32_t tempy = floor_y;
10846
6/6
✓ Branch 0 taken 53507 times.
✓ Branch 1 taken 53176 times.
✓ Branch 2 taken 2353 times.
✓ Branch 3 taken 104330 times.
✓ Branch 4 taken 52359 times.
✓ Branch 5 taken 51971 times.
106683 z=zc_max(0,zc_min(clk2start-clk2,clk2));
10847 106683 floor_y = y;
10848 106683 y=tempy-z;
10849 106683 old_y = y;
10850 }
10851 106683 }
10852
10853
4/4
✓ Branch 0 taken 4920 times.
✓ Branch 1 taken 724315 times.
✓ Branch 2 taken 978 times.
✓ Branch 3 taken 3942 times.
729235 if(stunclk && (clk&31)==1)
10854 3942 clk=0;
10855
10856 729235 return enemy::animate(index);
10857 746338 }
10858
10859 205276 void eTektite::drawshadow(BITMAP *dest,bool translucent)
10860 {
10861
5/6
✓ Branch 0 taken 35720 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 35720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11386 times.
✓ Branch 5 taken 24334 times.
205276 if(z<1 && fakez<1 && get_bit(quest_rules,qr_ENEMIESZAXIS))
10862 24334 return;
10863
10864 180942 int32_t tempy=yofs;
10865 180942 int32_t fdiv = frate/4;
10866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180942 times.
180942 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
10867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180942 times.
180942 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
10868 180942 efrate:((clk>=(frate>>1))?1:0);
10869 180942 flip = 0;
10870 180942 shadowtile = wpnsbuf[spr_shadow].tile;
10871
10872
1/2
✓ Branch 0 taken 180942 times.
✗ Branch 1 not taken.
180942 if(get_bit(quest_rules,qr_NEWENEMYTILES))
10873 {
10874
2/2
✓ Branch 0 taken 68140 times.
✓ Branch 1 taken 112802 times.
180942 if(misc==0)
10875 {
10876 68140 shadowtile+=f2;
10877 68140 }
10878
2/2
✓ Branch 0 taken 50479 times.
✓ Branch 1 taken 62323 times.
112802 else if(misc!=1)
10879 62323 shadowtile+=2;
10880 180942 }
10881 else
10882 {
10883 if(misc==0)
10884 {
10885 shadowtile += f2 ? 1 : 0;
10886 }
10887 else if(misc!=1)
10888 {
10889 ++shadowtile;
10890 }
10891 }
10892
10893 180942 yofs+=8;
10894
10895
4/4
✓ Branch 0 taken 11386 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 5992 times.
✓ Branch 3 taken 5394 times.
180942 if(!get_bit(quest_rules,qr_ENEMIESZAXIS) && misc==2)
10896 {
10897
6/6
✓ Branch 0 taken 2678 times.
✓ Branch 1 taken 2716 times.
✓ Branch 2 taken 320 times.
✓ Branch 3 taken 5074 times.
✓ Branch 4 taken 2572 times.
✓ Branch 5 taken 2502 times.
5394 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
10898 5394 }
10899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180942 times.
180942 if(!shadow_overpit(this))
10900 180942 enemy::drawshadow(dest,translucent);
10901 180942 yofs=tempy;
10902 205276 }
10903
10904 1341491 void eTektite::draw(BITMAP *dest)
10905 {
10906 1341491 update_enemy_frame();
10907 1341491 enemy::draw(dest);
10908 1341491 }
10909
10910 712 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10911 712 {
10912
2/4
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 356 times.
✗ Branch 3 not taken.
356 step=zslongToFix(guysbuf[id&0xFFF].step*100);
10913 356 superman=1;
10914 356 dir=8;
10915 356 hxofs=1000;
10916 356 mainguy=false;
10917 356 count_enemy=false;
10918
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 356 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
356 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10919 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10920 // al_trace("Enemy txsz:%i\n", txsz);
10921
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 356 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
356 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
10922
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 356 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
356 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
10923
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 356 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
356 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
10924
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 356 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
356 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
10925
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
10926
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
10927 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10928
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 356 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
356 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
10929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 356 times.
356 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10930 {
10931 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
10932 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10933 }
10934
10935
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 356 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
356 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
10936 356 }
10937
10938 201635 bool eItemFairy::animate(int32_t index)
10939 {
10940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201635 times.
201635 if(switch_hooked) return enemy::animate(index);
10941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201635 times.
201635 if(dying)
10942 return Dead(index);
10943
10944 //if(clk>32)
10945 201635 misc=1;
10946 201635 bool w=watch;
10947 201635 watch=false;
10948 201635 variable_walk_8(misc?3:0,0,8,spw_floater);
10949 201635 watch=w;
10950
10951
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 200659 times.
201635 if(clk==0)
10952 {
10953 976 removearmos(x,y,ffcactivated);
10954 976 }
10955
10956 201635 return enemy::animate(index);
10957 201635 }
10958
10959 404270 void eItemFairy::draw(BITMAP *dest)
10960 {
10961 //these are here to bypass compiler warnings about unused arguments
10962 404270 dest=dest;
10963 404270 }
10964
10965 1658 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10966 1658 {
10967 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
10968
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 829 times.
✓ Branch 2 taken 829 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 829 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 829 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 829 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 829 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 829 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 829 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 829 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 829 times.
✗ Branch 19 not taken.
829 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
10969 829 dir=8;
10970 829 movestatus=1;
10971 829 clk=0;
10972
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 step=0;
10973 //nets+720;
10974 829 SIZEflags = d->SIZEflags;
10975
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 829 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
829 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10976 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10977 // al_trace("Enemy txsz:%i\n", txsz);
10978
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 829 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
829 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10979
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 829 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
829 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10980
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 829 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
829 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10981
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 829 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
829 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10982
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10983
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10984 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10985
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 829 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
829 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 829 times.
829 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10987 {
10988 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10989 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10990 }
10991
10992
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 829 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
829 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10993 829 }
10994
10995 255104 bool ePeahat::animate(int32_t index)
10996 {
10997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255104 times.
255104 if(switch_hooked) return enemy::animate(index);
10998
2/4
✓ Branch 0 taken 255104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 255104 times.
255104 if(fallclk||drownclk) return enemy::animate(index);
10999
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 255026 times.
255104 if(slide())
11000 {
11001 78 return false;
11002 }
11003
11004
2/2
✓ Branch 0 taken 486 times.
✓ Branch 1 taken 254540 times.
255026 if(dying)
11005 486 return Dead(index);
11006
11007
2/2
✓ Branch 0 taken 253010 times.
✓ Branch 1 taken 1530 times.
254540 if(clk==0)
11008 {
11009 1530 removearmos(x,y,ffcactivated);
11010 1530 }
11011
11012
4/4
✓ Branch 0 taken 251760 times.
✓ Branch 1 taken 2780 times.
✓ Branch 2 taken 120106 times.
✓ Branch 3 taken 131654 times.
254540 if(stunclk==0 && clk>96)
11013 131654 misc=1;
11014
11015
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 252138 times.
254540 if(!watch)
11016
2/2
✓ Branch 0 taken 170944 times.
✓ Branch 1 taken 81194 times.
252138 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
11017
11018
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 154522 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
254540 if(get_bit(quest_rules,qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11019 {
11020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100018 times.
100018 if (moveflags & FLAG_USE_FAKE_Z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
11021 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
11022 100018 }
11023
11024
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 252138 times.
✓ Branch 2 taken 1634 times.
✓ Branch 3 taken 768 times.
254540 if(watch && get_bit(quest_rules,qr_PEAHATCLOCKVULN))
11025 1634 superman=0;
11026 else
11027
2/2
✓ Branch 0 taken 246414 times.
✓ Branch 1 taken 6492 times.
252906 superman=(movestatus && !get_bit(quest_rules,qr_ENEMIESZAXIS)) ? 1 : 0;
11028 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
11029
2/2
✓ Branch 0 taken 196019 times.
✓ Branch 1 taken 58521 times.
254540 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
11030 {
11031
2/2
✓ Branch 0 taken 2777 times.
✓ Branch 1 taken 193242 times.
196019 if ( stunclk ) --stunclk;
11032 196019 }
11033 58521 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
11034 //Pretty sure this was always an error. -Z ( 14FEB2019 )
11035
11036
11037
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 254318 times.
254540 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
11038
11039 254540 return enemy::animate(index);
11040 255104 }
11041
11042 88089 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
11043 {
11044 88089 int32_t tempy=yofs;
11045 88089 flip = 0;
11046 88089 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11047
11048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88089 times.
88089 if(!get_bit(quest_rules,qr_ENEMIESZAXIS))
11049 {
11050 yofs+=8;
11051 yofs+=int32_t(step/zslongToFix(dstep*10));
11052 }
11053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88089 times.
88089 if(!shadow_overpit(this))
11054 88089 enemy::drawshadow(dest,translucent);
11055 88089 yofs=tempy;
11056 88089 }
11057
11058 604054 void ePeahat::draw(BITMAP *dest)
11059 {
11060 604054 update_enemy_frame();
11061 604054 enemy::draw(dest);
11062 604054 }
11063
11064 925 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
11065 {
11066 925 int32_t wpnId = w->id;
11067 925 int32_t enemyHitWeapon = w->parentitem;
11068
11069
3/6
✓ Branch 0 taken 925 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 925 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 925 times.
925 if(dying || clk<0 || hclk>0)
11070 return 0;
11071
11072
4/4
✓ Branch 0 taken 731 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 102 times.
1057 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
11073 // fire boomerang, for nailing peahats
11074
4/6
✓ Branch 0 taken 731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 599 times.
✓ Branch 3 taken 132 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 132 times.
731 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
11075 701 return 0;
11076
11077 // Time for a kludge...
11078 224 int32_t s = superman;
11079 224 superman = 0;
11080 224 int32_t ret = enemy::takehit(w,realweap);
11081 224 superman = s;
11082
11083 // Anyway...
11084
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 141 times.
224 if(stunclk == 160)
11085 {
11086 141 clk2=0;
11087 141 movestatus=0;
11088 141 misc=0;
11089 141 clk=0;
11090 141 step=0;
11091 141 }
11092
11093 224 return ret;
11094 925 }
11095
11096 // auomatically kill off enemy (for rooms with ringleaders)
11097 void ePeahat::kickbucket()
11098 {
11099 hp=-1000; // don't call death_sfx()
11100 }
11101
11102 2908 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11103 2908 {
11104 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
11105
2/2
✓ Branch 0 taken 589 times.
✓ Branch 1 taken 865 times.
1454 if(dmisc1==0)
11106 {
11107 865 misc=-1; //Line of Sight leevers
11108 865 clk-=16;
11109 865 }
11110 1454 clk3 = 0;
11111 //nets+1460;
11112
1/2
✓ Branch 0 taken 1454 times.
✗ Branch 1 not taken.
1454 temprule=(get_bit(quest_rules,qr_NEWENEMYTILES)) != 0;
11113 1454 submerged = false;
11114 1454 SIZEflags = d->SIZEflags;
11115
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1454 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11116 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11117 // al_trace("Enemy txsz:%i\n", txsz);
11118
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1454 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11119
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1454 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11120
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1454 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11121
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1454 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11122
1/2
✓ Branch 0 taken 1454 times.
✗ Branch 1 not taken.
1454 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11123
1/2
✓ Branch 0 taken 1454 times.
✗ Branch 1 not taken.
1454 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11124 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11125
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1454 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
1454 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11127 {
11128 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11129 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11130 }
11131
11132
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1454 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1454 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11133 1454 }
11134
11135 bool eLeever::isSubmerged() const
11136 {
11137 Z_scripterrlog("misc is: %d\n", misc);
11138 return misc <= 0;
11139
11140 }
11141
11142 437382 bool eLeever::animate(int32_t index)
11143 {
11144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 437382 times.
437382 if(switch_hooked) return enemy::animate(index);
11145
2/4
✓ Branch 0 taken 437382 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 437382 times.
437382 if(fallclk||drownclk)
11146 {
11147 return enemy::animate(index);
11148 }
11149
2/2
✓ Branch 0 taken 15768 times.
✓ Branch 1 taken 421614 times.
437382 if(dying)
11150 15768 return Dead(index);
11151
11152
2/2
✓ Branch 0 taken 402593 times.
✓ Branch 1 taken 19021 times.
421614 if(clk==0)
11153 {
11154 19021 removearmos(x,y,ffcactivated);
11155 19021 }
11156
11157
4/4
✓ Branch 0 taken 342846 times.
✓ Branch 1 taken 78768 times.
✓ Branch 2 taken 2325 times.
✓ Branch 3 taken 340521 times.
421614 if(clk>=0 && !slide())
11158 {
11159 // switch(d->misc1)
11160
2/2
✓ Branch 0 taken 144887 times.
✓ Branch 1 taken 195634 times.
340521 switch(dmisc1)
11161 {
11162 case 0: //line of sight
11163 case 2:
11164
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 62553 times.
✓ Branch 2 taken 15911 times.
✓ Branch 3 taken 14998 times.
✓ Branch 4 taken 6683 times.
✓ Branch 5 taken 40341 times.
✓ Branch 6 taken 1697 times.
✓ Branch 7 taken 2704 times.
144887 switch(misc) //is this leever active
11165 {
11166 case -1: //submerged
11167 {
11168
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62553 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
62553 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
11169
4/4
✓ Branch 0 taken 7609 times.
✓ Branch 1 taken 54944 times.
✓ Branch 2 taken 7582 times.
✓ Branch 3 taken 27 times.
62553 if((dmisc1==2)&&(zc_oldrand()&255))
11170 {
11171 7582 break;
11172 }
11173
11174 54971 int32_t active=0;
11175
11176
2/2
✓ Branch 0 taken 389366 times.
✓ Branch 1 taken 54971 times.
444337 for(int32_t i=0; i<guys.Count(); i++)
11177 {
11178
4/4
✓ Branch 0 taken 325752 times.
✓ Branch 1 taken 63614 times.
✓ Branch 2 taken 216880 times.
✓ Branch 3 taken 108872 times.
389366 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
11179 {
11180 108872 ++active;
11181 108872 }
11182 389366 }
11183
11184
2/2
✓ Branch 0 taken 54200 times.
✓ Branch 1 taken 771 times.
54971 if(active<((dmisc1==2)?1:2))
11185 {
11186 771 misc=0; //activate this one
11187 771 clk3=1; //This needs to be set so that it knows that it's being emerged of it's own will and not because it got stunned.
11188 771 }
11189 }
11190 54971 break;
11191
11192 case 0:
11193 {
11194
11195
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15911 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15911 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
11196 {
11197 misc=1;
11198 clk2=0;
11199 }
11200
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 15875 times.
15911 else if (clk3<=0)
11201 {
11202 36 misc = -1;
11203 36 break;
11204 }
11205 15875 int32_t s=0;
11206
11207
2/2
✓ Branch 0 taken 106125 times.
✓ Branch 1 taken 15875 times.
122000 for(int32_t i=0; i<guys.Count(); i++)
11208 {
11209
4/4
✓ Branch 0 taken 69053 times.
✓ Branch 1 taken 37072 times.
✓ Branch 2 taken 66972 times.
✓ Branch 3 taken 2081 times.
106125 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
11210 {
11211 2081 ++s;
11212 2081 }
11213 106125 }
11214
11215
2/2
✓ Branch 0 taken 2081 times.
✓ Branch 1 taken 13794 times.
15875 if(s>0)
11216 {
11217 2081 break;
11218 }
11219
11220 13794 int32_t d2=zc_oldrand()&1;
11221
11222
2/2
✓ Branch 0 taken 4512 times.
✓ Branch 1 taken 9282 times.
13794 if(HeroDir()>=left)
11223 {
11224 9282 d2+=2;
11225 9282 }
11226
11227
4/4
✓ Branch 0 taken 13189 times.
✓ Branch 1 taken 605 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 12906 times.
13794 if(canplace(d2) || canplace(d2^1))
11228 {
11229 888 misc=1;
11230 888 clk2=0;
11231 888 clk=0;
11232 888 }
11233 }
11234 13794 break;
11235
11236 case 1:
11237
11238
3/8
✓ Branch 0 taken 14121 times.
✓ Branch 1 taken 877 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14121 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14998 if(++clk2>16||(!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
11239
11240 14998 break;
11241
11242 case 2:
11243
11244
3/8
✓ Branch 0 taken 5872 times.
✓ Branch 1 taken 811 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5872 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6683 if(++clk2>24||(!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
11245
11246 6683 break;
11247
11248 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
11249 case 3:
11250
11251
5/6
✓ Branch 0 taken 38099 times.
✓ Branch 1 taken 2242 times.
✓ Branch 2 taken 38099 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2066 times.
✓ Branch 5 taken 36033 times.
40341 if(stunclk || frozenclock || watch) break;
11252
11253
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 35962 times.
36033 if(scored) dir^=1;
11254
11255
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 35837 times.
36033 if(!canmove(dir,false)) misc=4;
11256 35837 else move(zslongToFix(dstep*100));
11257
11258 36033 break;
11259
11260 case 4:
11261
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1697 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1697 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
11262
2/2
✓ Branch 0 taken 1515 times.
✓ Branch 1 taken 182 times.
1697 if(--clk2<=16)
11263 {
11264 182 misc=5;
11265 182 clk=8;
11266 182 }
11267
11268 1697 break;
11269
11270 case 5:
11271
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2704 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
11272
2/2
✓ Branch 0 taken 2541 times.
✓ Branch 1 taken 163 times.
2704 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
11273
11274 2704 break;
11275 } // switch(misc)
11276
11277 144887 break;
11278
11279 default: //random
11280 // step=d->misc3/100.0;
11281
11282 195634 step=zslongToFix(dmisc3*100);
11283
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 195634 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
195634 if (get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
11284 else if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
11285 {
11286 if (clk2 < 48) clk2+=2;
11287 if (clk2 >= 300) clk2-=2;
11288 }
11289
11290
2/2
✓ Branch 0 taken 22063 times.
✓ Branch 1 taken 173571 times.
195634 if(clk2<32) misc=1;
11291
2/2
✓ Branch 0 taken 11123 times.
✓ Branch 1 taken 162448 times.
173571 else if(clk2<48) misc=2;
11292
2/2
✓ Branch 0 taken 115546 times.
✓ Branch 1 taken 46902 times.
162448 else if(clk2<300)
11293 {
11294 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
11295 {
11296 fix_coords();
11297 }*/
11298 115546 misc=3;
11299 115546 step = zslongToFix(dstep*100);
11300 115546 }
11301
2/2
✓ Branch 0 taken 4107 times.
✓ Branch 1 taken 42795 times.
46902 else if(clk2<316) misc=2;
11302
2/2
✓ Branch 0 taken 21211 times.
✓ Branch 1 taken 21584 times.
42795 else if(clk2<412) misc=1;
11303
2/2
✓ Branch 0 taken 21431 times.
✓ Branch 1 taken 153 times.
21584 else if(clk2<540)
11304 {
11305 21431 misc=0;
11306 21431 step=0;
11307 21431 }
11308 153 else clk2=0;
11309
11310
2/2
✓ Branch 0 taken 194951 times.
✓ Branch 1 taken 683 times.
195634 if(clk2==48) clk=0;
11311
11312 // variable_walk(d->rate, d->homing, 0);
11313 195634 variable_walk(rate, homing, 0);
11314 195634 } // switch(dmisc1)
11315 340521 }
11316
11317 421614 hxofs=(misc>=2)?0:1000;
11318 421614 return enemy::animate(index);
11319 437382 }
11320
11321 26983 bool eLeever::canplace(int32_t d2)
11322 {
11323 26983 int32_t nx=HeroX();
11324 26983 int32_t ny=HeroY();
11325
11326
2/2
✓ Branch 0 taken 8782 times.
✓ Branch 1 taken 18201 times.
26983 if(d2<left) ny&=0xF0;
11327 18201 else nx&=0xF0;
11328
11329
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4361 times.
✓ Branch 2 taken 4421 times.
✓ Branch 3 taken 9083 times.
✓ Branch 4 taken 9118 times.
26983 switch(d2)
11330 {
11331 // case up: ny-=((d->misc1==0)?32:48); break;
11332 // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break;
11333 // case left: nx-=((d->misc1==0)?32:48); break;
11334 // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break;
11335 case up:
11336
2/2
✓ Branch 0 taken 4333 times.
✓ Branch 1 taken 28 times.
4361 ny-=((dmisc1==0||dmisc1==2)?32:48);
11337 4361 break;
11338
11339 case down:
11340
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 4390 times.
4421 ny+=((dmisc1==0||dmisc1==2)?32:48);
11341
11342
4/4
✓ Branch 0 taken 2346 times.
✓ Branch 1 taken 2075 times.
✓ Branch 2 taken 2337 times.
✓ Branch 3 taken 9 times.
4421 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
11343
11344 4421 break;
11345
11346 case left:
11347
2/2
✓ Branch 0 taken 8483 times.
✓ Branch 1 taken 600 times.
9083 nx-=((dmisc1==0||dmisc1==2)?32:48);
11348 9083 break;
11349
11350 case right:
11351
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 8523 times.
9118 nx+=((dmisc1==0||dmisc1==2)?32:48);
11352
11353
4/4
✓ Branch 0 taken 5771 times.
✓ Branch 1 taken 3347 times.
✓ Branch 2 taken 5216 times.
✓ Branch 3 taken 555 times.
9118 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
11354
11355 9118 break;
11356 }
11357
11358
4/4
✓ Branch 0 taken 9891 times.
✓ Branch 1 taken 17092 times.
✓ Branch 2 taken 4421 times.
✓ Branch 3 taken 5470 times.
26983 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
11359 21513 return false;
11360
11361
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 5069 times.
5470 if(d2>=left)
11362
4/4
✓ Branch 0 taken 2469 times.
✓ Branch 1 taken 2600 times.
✓ Branch 2 taken 4582 times.
✓ Branch 3 taken 487 times.
5069 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
11363 4582 return false;
11364
11365 888 x=nx;
11366 888 y=ny;
11367 888 dir=d2^1;
11368 888 return true;
11369 26983 }
11370
11371 438209 void eLeever::draw(BITMAP *dest)
11372 {
11373 // cs=d->cset;
11374 438209 cs=dcset;
11375 438209 update_enemy_frame();
11376
2/4
✓ Branch 0 taken 438209 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 438209 times.
438209 if(!fallclk&&!drownclk)
11377 {
11378
2/2
✓ Branch 0 taken 258514 times.
✓ Branch 1 taken 179695 times.
438209 switch(misc)
11379 {
11380 case -1:
11381 case 0:
11382 179695 return;
11383 }
11384 258514 }
11385
11386 258514 enemy::draw(dest);
11387 438209 }
11388
11389 922 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11390 922 {
11391 //zprint2("eWallM::eWallM\n");
11392 461 hashero=false;
11393 //nets+1000;
11394 461 SIZEflags = d->SIZEflags;
11395
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
461 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11396 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11397 // al_trace("Enemy txsz:%i\n", txsz);
11398
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
461 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11399
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11400
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11401
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11402
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11403
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11404 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11405
1/4
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11407 {
11408 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11409 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11410 }
11411
11412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11413 461 }
11414
11415 293665 bool eWallM::animate(int32_t index)
11416 {
11417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 293665 times.
293665 if(switch_hooked) return enemy::animate(index);
11418
2/4
✓ Branch 0 taken 293665 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 293665 times.
293665 if(fallclk||drownclk)
11419 {
11420 return enemy::animate(index);
11421 }
11422
2/2
✓ Branch 0 taken 5754 times.
✓ Branch 1 taken 287911 times.
293665 if(dying)
11423 5754 return Dead(index);
11424
11425
2/2
✓ Branch 0 taken 269557 times.
✓ Branch 1 taken 18354 times.
287911 if(clk==0)
11426 {
11427 18354 removearmos(x,y,ffcactivated);
11428 18354 }
11429
11430 287911 hxofs=1000;
11431
2/2
✓ Branch 0 taken 73358 times.
✓ Branch 1 taken 214553 times.
287911 if(misc==0) //inside wall, ready to spawn?
11432 {
11433 //zprint2("Wallmaster is ready to spawn, clk is: %d\n",clk);
11434 //zprint2("frame is: %d\n",frame);
11435 //zprint2("wallm_load_clk is: %d\n",wallm_load_clk);
11436
4/4
✓ Branch 0 taken 142333 times.
✓ Branch 1 taken 72220 times.
✓ Branch 2 taken 8075 times.
✓ Branch 3 taken 134258 times.
214553 if(frame-wallm_load_clk>80 && clk>=0)
11437 {
11438 //zprint2("getting wall\n");
11439 134258 int32_t wall=hero_on_wall();
11440 //zprint2("Wallmaster wall is %d\n",wall);
11441 134258 int32_t wallm_cnt=0;
11442
11443
2/2
✓ Branch 0 taken 1042190 times.
✓ Branch 1 taken 134258 times.
1176448 for(int32_t i=0; i<guys.Count(); i++)
11444
2/2
✓ Branch 0 taken 396987 times.
✓ Branch 1 taken 645203 times.
1687393 if(((enemy*)guys.spr(i))->family==eeWALLM)
11445 {
11446 645203 int32_t m=((enemy*)guys.spr(i))->misc;
11447
11448
4/4
✓ Branch 0 taken 28942 times.
✓ Branch 1 taken 616261 times.
✓ Branch 2 taken 17774 times.
✓ Branch 3 taken 11168 times.
645203 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
11449 {
11450 11168 ++wallm_cnt;
11451 11168 }
11452 645203 }
11453
11454
2/2
✓ Branch 0 taken 133802 times.
✓ Branch 1 taken 456 times.
134258 if(wall>0)
11455 {
11456 456 --wall;
11457 456 misc=1; //emerging from the wall?
11458 //zprint2("Wallmaster is emerging\n");
11459 456 clk2=0;
11460 456 clk3=wall^1;
11461 456 wallm_load_clk=frame;
11462
11463
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 188 times.
456 if(wall<=down)
11464 {
11465
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 221 times.
268 if(HeroDir()==left)
11466 47 dir=right;
11467 else
11468 221 dir=left;
11469 268 }
11470 else
11471 {
11472
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 150 times.
188 if(HeroDir()==up)
11473 38 dir=down;
11474 else
11475 150 dir=up;
11476 }
11477
11478
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 60 times.
456 switch(wall)
11479 {
11480 case up:
11481 144 y=0;
11482 144 break;
11483
11484 case down:
11485 124 y=160;
11486 124 break;
11487
11488 case left:
11489 128 x=0;
11490 128 break;
11491
11492 case right:
11493 60 x=240;
11494 60 break;
11495 }
11496
11497 //zprint2("Wallmaster (p1) x is %d\n",x);
11498 //zprint2("Wallmaster (p1) y is %d\n",y);
11499
11500
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 221 times.
✓ Branch 4 taken 47 times.
456 switch(dir)
11501 {
11502 case up:
11503 150 y=(HeroY()+48-(wallm_cnt&1)*12);
11504 150 flip=wall&1;
11505 150 break;
11506
11507 case down:
11508 38 y=(HeroY()-48+(wallm_cnt&1)*12);
11509 38 flip=((wall&1)^1)+2;
11510 38 break;
11511
11512 case left:
11513 221 x=(HeroX()+48-(wallm_cnt&1)*12);
11514 221 flip=(wall==up?2:0)+1;
11515 221 break;
11516
11517 case right:
11518 47 x=(HeroX()-48+(wallm_cnt&1)*12);
11519 47 flip=(wall==up?2:0);
11520 47 break;
11521 }
11522
11523 //zprint2("Wallmaster (p2) x is %d\n",x);
11524 //zprint2("Wallmaster (p2) y is %d\n",y);
11525 456 }
11526 134258 }
11527 214553 }
11528 else
11529 73358 wallm_crawl();
11530
11531 287911 return enemy::animate(index);
11532 293665 }
11533
11534 73358 void eWallM::wallm_crawl()
11535 {
11536 73358 bool w=watch;
11537 73358 hxofs=0;
11538
11539
2/2
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 72882 times.
73358 if(slide())
11540 {
11541 476 return;
11542 }
11543
11544 // if(dying || watch || (!hashero && stunclk))
11545
6/8
✓ Branch 0 taken 72882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72593 times.
✓ Branch 3 taken 289 times.
✓ Branch 4 taken 58915 times.
✓ Branch 5 taken 13678 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 58915 times.
72882 if(dying || (!hashero && ( stunclk || frozenclock )))
11546 {
11547 13678 return;
11548 }
11549
11550 59204 watch=false;
11551 59204 ++clk2;
11552 // Misc1: slightly different movement
11553 //zprint2("wallmaster crawl\n");
11554 //zprint2("wallmaster tmpdstep is %d\n",tmpdstep);
11555 59204 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
11556
11557 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
11558 //zprint2("wallmaster crawl tmpmisc is: %d\n", tmpmisc);
11559 //zprint2("wallmaster crawl tmpmisc4 is: %d\n", tmpmisc4);
11560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59204 times.
59204 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
11561 //zprint2("wallmaster crawl misc is: %d\n", misc);
11562
5/6
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 53580 times.
✓ Branch 2 taken 4384 times.
✓ Branch 3 taken 1240 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4384 times.
59204 if(w&&misc>=3&&misc<=5)
11563 {
11564 4384 --clk2;
11565 4384 }
11566
11567
4/4
✓ Branch 0 taken 25333 times.
✓ Branch 1 taken 27380 times.
✓ Branch 2 taken 6388 times.
✓ Branch 3 taken 103 times.
59204 switch(misc)
11568 {
11569 case 1:
11570 case 2:
11571 27380 zc_swap(dir,clk3);
11572 27380 move(step);
11573 27380 zc_swap(dir,clk3);
11574 27380 break;
11575
11576 case 3:
11577 case 4:
11578 case 5:
11579
2/2
✓ Branch 0 taken 4384 times.
✓ Branch 1 taken 20949 times.
25333 if(w)
11580 {
11581 4384 watch=w;
11582 4384 return;
11583 }
11584
11585 20949 move(step);
11586 20949 break;
11587
11588 case 6:
11589 case 7:
11590 6388 zc_swap(dir,clk3);
11591 6388 dir^=1;
11592 6388 move(step);
11593 6388 dir^=1;
11594 6388 zc_swap(dir,clk3);
11595 6388 break;
11596
11597 default:
11598 103 misc=0;
11599 103 break;
11600 }
11601
11602 54820 watch=w;
11603 73358 }
11604
11605 3 void eWallM::grabhero()
11606 {
11607 3 hashero=true;
11608 3 superman=1;
11609 3 }
11610
11611 293941 void eWallM::draw(BITMAP *dest)
11612 {
11613 293941 dummy_bool[1]=hashero;
11614 293941 update_enemy_frame();
11615
11616
4/6
✓ Branch 0 taken 214543 times.
✓ Branch 1 taken 79398 times.
✓ Branch 2 taken 214543 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 214543 times.
293941 if(misc>0 || fallclk||drownclk)
11617 {
11618 79398 masked_draw(dest,16,playing_field_offset+16,224,144);
11619 79398 }
11620
11621 // enemy::draw(dest);
11622 // tile = clk&8 ? 128:129;
11623 293941 }
11624
11625 bool eWallM::isSubmerged() const
11626 {
11627 return ( !misc );
11628 }
11629
11630 1310 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11631 1310 {
11632
1/2
✓ Branch 0 taken 655 times.
✗ Branch 1 not taken.
655 ox=x; //original x
11633
1/2
✓ Branch 0 taken 655 times.
✗ Branch 1 not taken.
655 oy=y; //original y
11634
3/4
✓ Branch 0 taken 655 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 589 times.
655 if(get_bit(quest_rules,qr_TRAPPOSFIX))
11635 {
11636
3/6
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
66 yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
11637 66 }
11638
11639 655 mainguy=false;
11640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 655 times.
655 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
11641 //nets+420;
11642 655 dummy_int[1]=0;
11643 655 SIZEflags = d->SIZEflags;
11644
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 655 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
655 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11645 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11646 // al_trace("Enemy txsz:%i\n", txsz);
11647
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 655 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
655 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11648
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 655 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
655 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11649
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 655 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
655 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11650
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 655 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
655 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11651
1/2
✓ Branch 0 taken 655 times.
✗ Branch 1 not taken.
655 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11652
1/2
✓ Branch 0 taken 655 times.
✗ Branch 1 not taken.
655 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11653 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11654
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 655 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
655 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 655 times.
655 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11656 {
11657 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11658 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11659 }
11660
11661
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 655 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
655 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11662 655 }
11663
11664 467603 bool eTrap::animate(int32_t index)
11665 {
11666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467603 times.
467603 if(switch_hooked) return enemy::animate(index);
11667
2/4
✓ Branch 0 taken 467603 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 467603 times.
467603 if(fallclk||drownclk) return enemy::animate(index);
11668
2/2
✓ Branch 0 taken 458437 times.
✓ Branch 1 taken 9166 times.
467603 if(clk<0)
11669 9166 return enemy::animate(index);
11670
11671
2/2
✓ Branch 0 taken 429463 times.
✓ Branch 1 taken 28974 times.
458437 if(clk==0)
11672 {
11673 28974 removearmos(x,y,ffcactivated);
11674 28974 }
11675
11676
2/2
✓ Branch 0 taken 120391 times.
✓ Branch 1 taken 338046 times.
458437 if(misc==0) // waiting
11677 {
11678 338046 ox = x;
11679 338046 oy = y;
11680 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11681 338046 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11682
11683
4/4
✓ Branch 0 taken 110783 times.
✓ Branch 1 taken 227263 times.
✓ Branch 2 taken 65925 times.
✓ Branch 3 taken 44858 times.
338046 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
11684 {
11685 44858 dir=down;
11686 44858 }
11687
4/4
✓ Branch 0 taken 197543 times.
✓ Branch 1 taken 95645 times.
✓ Branch 2 taken 65925 times.
✓ Branch 3 taken 131618 times.
293188 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
11688 {
11689 131618 dir=right;
11690 131618 }
11691
4/4
✓ Branch 0 taken 101314 times.
✓ Branch 1 taken 60256 times.
✓ Branch 2 taken 65925 times.
✓ Branch 3 taken 35389 times.
161570 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
11692 {
11693 35389 dir=up;
11694 35389 }
11695 else
11696 {
11697 126181 dir=left;
11698 }
11699
11700 338046 int32_t d2=lined_up(15,true);
11701
11702
4/4
✓ Branch 0 taken 116768 times.
✓ Branch 1 taken 221278 times.
✓ Branch 2 taken 623238 times.
✓ Branch 3 taken 292222 times.
550386 if(((d2<left || d2 > right) && (dmisc1==1)) ||
11703
2/2
✓ Branch 0 taken 111924 times.
✓ Branch 1 taken 194310 times.
292222 ((d2>down) && (dmisc1==2)) ||
11704
2/2
✓ Branch 0 taken 105187 times.
✓ Branch 1 taken 102095 times.
194310 ((d2>right) && (!dmisc1)) ||
11705
2/2
✓ Branch 0 taken 212340 times.
✓ Branch 1 taken 44436 times.
207282 ((d2<l_up) && (dmisc1==4)) ||
11706
3/4
✓ Branch 0 taken 212340 times.
✓ Branch 1 taken 169968 times.
✓ Branch 2 taken 212340 times.
✗ Branch 3 not taken.
44436 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
11707
3/4
✓ Branch 0 taken 212340 times.
✓ Branch 1 taken 42970 times.
✓ Branch 2 taken 212340 times.
✗ Branch 3 not taken.
169968 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
11708 {
11709 1372182 d2=-1;
11710 1372182 }
11711
11712
4/4
✓ Branch 0 taken 9495 times.
✓ Branch 1 taken 159181 times.
✓ Branch 2 taken 8567 times.
✓ Branch 3 taken 928 times.
168676 if(d2!=-1 && trapmove(d2))
11713 {
11714 928 dir=d2;
11715 928 misc=1;
11716 928 clk2=(dir==down)?3:0;
11717 928 }
11718 168676 }
11719
11720
2/2
✓ Branch 0 taken 256246 times.
✓ Branch 1 taken 32821 times.
289067 if(misc==1) // charging
11721 {
11722 32821 clk2=(clk2+1)&3;
11723 32821 step=(clk2==3)?1:2;
11724
11725
4/4
✓ Branch 0 taken 32772 times.
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 810 times.
✓ Branch 3 taken 31962 times.
32821 if(!trapmove(dir) || clip())
11726 {
11727 859 misc=2;
11728
11729
1/2
✓ Branch 0 taken 859 times.
✗ Branch 1 not taken.
859 if(dir<l_up)
11730 {
11731 859 dir=dir^1;
11732 859 }
11733 else
11734 {
11735 dir=dir^3;
11736 }
11737 859 }
11738 else
11739 {
11740 31962 sprite::move(step);
11741 }
11742 32821 }
11743
11744
2/2
✓ Branch 0 taken 199710 times.
✓ Branch 1 taken 89357 times.
289067 if(misc==2) // retreating
11745 {
11746 89357 step=(++clk2&1)?1:0;
11747
11748
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 11824 times.
✓ Branch 2 taken 33542 times.
✓ Branch 3 taken 10863 times.
✓ Branch 4 taken 33128 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
89357 switch(dir)
11749 {
11750 case up:
11751
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 11719 times.
11824 if(int32_t(y)<=oy) goto trap_rest;
11752 11719 else sprite::move(step);
11753
11754 11719 break;
11755
11756 case left:
11757
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 33349 times.
33542 if(int32_t(x)<=ox) goto trap_rest;
11758 33349 else sprite::move(step);
11759
11760 33349 break;
11761
11762 case down:
11763
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 10759 times.
10863 if(int32_t(y)>=oy) goto trap_rest;
11764 10759 else sprite::move(step);
11765
11766 10759 break;
11767
11768 case right:
11769
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 32923 times.
33128 if(int32_t(x)>=ox) goto trap_rest;
11770 32923 else sprite::move(step);
11771
11772 32923 break;
11773
11774 case l_up:
11775 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
11776 else sprite::move(step);
11777
11778 break;
11779
11780 case r_up:
11781 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
11782 else sprite::move(step);
11783
11784 break;
11785
11786 case l_down:
11787 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
11788 else sprite::move(step);
11789
11790 break;
11791
11792 case r_down:
11793 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
11794 else sprite::move(step);
11795
11796 break;
11797 trap_rest:
11798 {
11799 607 x=ox;
11800 607 y=oy;
11801 607 misc=0;
11802 }
11803 607 }
11804 89357 }
11805
11806 289067 return enemy::animate(index);
11807 298233 }
11808
11809 42316 bool eTrap::trapmove(int32_t ndir)
11810 {
11811
2/2
✓ Branch 0 taken 28049 times.
✓ Branch 1 taken 14267 times.
42316 if(get_bit(quest_rules,qr_MEANTRAPS))
11812 {
11813
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 26709 times.
28049 if(tmpscr->flags2&fFLOATTRAPS)
11814 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
11815
11816 26709 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
11817 }
11818
11819
6/6
✓ Branch 0 taken 6244 times.
✓ Branch 1 taken 8023 times.
✓ Branch 2 taken 4374 times.
✓ Branch 3 taken 1870 times.
✓ Branch 4 taken 1608 times.
✓ Branch 5 taken 2766 times.
14267 if(oy==80 && !(ndir==left || ndir == right))
11820 2766 return false;
11821
11822
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11501 if(ox==128 && !(ndir==up || ndir==down))
11823 return false;
11824
11825
3/4
✓ Branch 0 taken 4333 times.
✓ Branch 1 taken 7168 times.
✓ Branch 2 taken 4333 times.
✗ Branch 3 not taken.
11501 if(oy<80 && ndir==up)
11826 return false;
11827
11828
3/4
✓ Branch 0 taken 3690 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 3690 times.
✗ Branch 3 not taken.
11501 if(oy>80 && ndir==down)
11829 return false;
11830
11831
4/4
✓ Branch 0 taken 5854 times.
✓ Branch 1 taken 5647 times.
✓ Branch 2 taken 5136 times.
✓ Branch 3 taken 718 times.
11501 if(ox<128 && ndir==left)
11832 718 return false;
11833
11834
4/4
✓ Branch 0 taken 5647 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 5159 times.
✓ Branch 3 taken 488 times.
10783 if(ox>128 && ndir==right)
11835 488 return false;
11836
11837
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 2207 times.
✓ Branch 3 taken 2929 times.
✓ Branch 4 taken 2207 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy<80 && ndir==l_up)
11838 return false;
11839
11840
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 1809 times.
✓ Branch 3 taken 3327 times.
✓ Branch 4 taken 1809 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy>80 && ndir==l_down)
11841 return false;
11842
11843
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 2126 times.
✓ Branch 3 taken 3033 times.
✓ Branch 4 taken 2126 times.
✗ Branch 5 not taken.
10295 if(ox>128 && oy<80 && ndir==r_up)
11844 return false;
11845
11846
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 1881 times.
✓ Branch 3 taken 3278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1881 times.
10295 if(ox>128 && oy>80 && ndir==r_down)
11847 return false;
11848
11849 10295 return true;
11850 42316 }
11851
11852 32772 bool eTrap::clip()
11853 {
11854
2/2
✓ Branch 0 taken 1499 times.
✓ Branch 1 taken 31273 times.
32772 if(get_bit(quest_rules,qr_MEANPLACEDTRAPS))
11855 {
11856
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 550 times.
✓ Branch 2 taken 342 times.
✓ Branch 3 taken 344 times.
✓ Branch 4 taken 263 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
1499 switch(dir)
11857 {
11858 case up:
11859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550 times.
550 if(y<=0) return true;
11860
11861 550 break;
11862
11863 case down:
11864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 342 times.
342 if(y>=160) return true;
11865
11866 342 break;
11867
11868 case left:
11869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344 times.
344 if(x<=0) return true;
11870
11871 344 break;
11872
11873 case right:
11874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 263 times.
263 if(x>=240) return true;
11875
11876 263 break;
11877
11878 case l_up:
11879 if(y<=0||x<=0) return true;
11880
11881 break;
11882
11883 case l_down:
11884 if(y>=160||x<=0) return true;
11885
11886 break;
11887
11888 case r_up:
11889 if(y<=0||x>=240) return true;
11890
11891 break;
11892
11893 case r_down:
11894 if(y>=160||x>=240) return true;
11895
11896 break;
11897 }
11898
11899 1499 return false;
11900 }
11901 else
11902 {
11903
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3520 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 11694 times.
✓ Branch 4 taken 12148 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
31273 switch(dir)
11904 {
11905 case up:
11906
4/4
✓ Branch 0 taken 3466 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 3330 times.
✓ Branch 3 taken 136 times.
3520 if(oy>80 && y<=86) return true;
11907
11908 3384 break;
11909
11910 case down:
11911
4/4
✓ Branch 0 taken 3830 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 3687 times.
✓ Branch 3 taken 143 times.
3911 if(oy<80 && y>=80) return true;
11912
11913 3768 break;
11914
11915 case left:
11916
4/4
✓ Branch 0 taken 11604 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 11342 times.
✓ Branch 3 taken 262 times.
11694 if(ox>128 && x<=124) return true;
11917
11918 11432 break;
11919
11920 case right:
11921
3/4
✓ Branch 0 taken 12148 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11879 times.
✓ Branch 3 taken 269 times.
12148 if(ox<120 && x>=116) return true;
11922
11923 11879 break;
11924
11925 case l_up:
11926 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
11927
11928 break;
11929
11930 case l_down:
11931 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
11932
11933 break;
11934
11935 case r_up:
11936 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
11937
11938 break;
11939
11940 case r_down:
11941 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
11942
11943 break;
11944 }
11945
11946 30463 return false;
11947 }
11948 32772 }
11949
11950 467895 void eTrap::draw(BITMAP *dest)
11951 {
11952 467895 update_enemy_frame();
11953 467895 enemy::draw(dest);
11954 467895 }
11955
11956 2358 int32_t eTrap::takehit(weapon*,weapon*)
11957 {
11958 2358 return 0;
11959 }
11960
11961 280 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11962 280 {
11963 140 lasthit=-1;
11964 140 lasthitclk=0;
11965 140 mainguy=false;
11966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
11967
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 step=2;
11968
3/6
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
140 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
11969 {
11970
2/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
60 dir=(x<=112)?right:left;
11971 60 }
11972 else
11973 {
11974
2/4
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
80 dir=(y<=72)?down:up;
11975 }
11976
11977
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(get_bit(quest_rules,qr_TRAPPOSFIX))
11978 {
11979 yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
11980 }
11981
11982 //nets+((id==eTRAP_LR)?540:520);
11983 140 dummy_int[1]=0;
11984 140 SIZEflags = d->SIZEflags;
11985
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11986 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11987 // al_trace("Enemy txsz:%i\n", txsz);
11988
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11989
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11990
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11991
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11992
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11993
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11994 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11995
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11997 {
11998 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11999 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12000 }
12001
12002
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
12003 140 }
12004
12005 83320 bool eTrap2::animate(int32_t index)
12006 {
12007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83320 times.
83320 if(switch_hooked) return enemy::animate(index);
12008
2/4
✓ Branch 0 taken 83320 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 83320 times.
83320 if(fallclk||drownclk) return enemy::animate(index);
12009
2/2
✓ Branch 0 taken 81360 times.
✓ Branch 1 taken 1960 times.
83320 if(clk<0)
12010 1960 return enemy::animate(index);
12011
12012
2/2
✓ Branch 0 taken 5158 times.
✓ Branch 1 taken 76202 times.
81360 if(clk==0)
12013 {
12014 5158 removearmos(x,y,ffcactivated);
12015 5158 }
12016
12017
2/2
✓ Branch 0 taken 76968 times.
✓ Branch 1 taken 4392 times.
81360 if(!get_bit(quest_rules,qr_PHANTOMPLACEDTRAPS))
12018 {
12019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4392 times.
4392 if(lasthitclk>0)
12020 {
12021 --lasthitclk;
12022 }
12023 else
12024 {
12025 4392 lasthit=-1;
12026 }
12027
12028 4392 bool hitenemy=false;
12029
12030
2/2
✓ Branch 0 taken 57096 times.
✓ Branch 1 taken 4392 times.
61488 for(int32_t j=0; j<guys.Count(); j++)
12031 {
12032
3/4
✓ Branch 0 taken 52704 times.
✓ Branch 1 taken 4392 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52704 times.
57096 if((j!=index) && (lasthit!=j))
12033 {
12034
1/2
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
52704 if(hit(guys.spr(j)))
12035 {
12036 lasthit=j;
12037 lasthitclk=10;
12038 hitenemy=true;
12039 guys.spr(j)->lasthit=index;
12040 guys.spr(j)->lasthitclk=10;
12041 // guys.spr(j)->dir=guys.spr(j)->dir^1;
12042 }
12043 52704 }
12044 57096 }
12045
12046
4/6
✓ Branch 0 taken 4344 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 4344 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4344 times.
4392 if(!trapmove(dir) || clip() || hitenemy)
12047 {
12048
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(!trapmove(dir) || clip())
12049 {
12050 48 lasthit=-1;
12051 48 lasthitclk=0;
12052 48 }
12053
12054
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(get_bit(quest_rules,qr_MORESOUNDS))
12055 sfx(WAV_ZN1TAP,pan(int32_t(x)));
12056
12057 48 dir=dir^1;
12058 48 }
12059
12060 4392 sprite::move(step);
12061 4392 }
12062 else
12063 {
12064
3/4
✓ Branch 0 taken 75261 times.
✓ Branch 1 taken 1707 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 75261 times.
76968 if(!trapmove(dir) || clip())
12065 {
12066
1/2
✓ Branch 0 taken 1707 times.
✗ Branch 1 not taken.
1707 if(get_bit(quest_rules,qr_MORESOUNDS))
12067 sfx(WAV_ZN1TAP,pan(int32_t(x)));
12068
12069 1707 dir=dir^1;
12070 1707 }
12071
12072 76968 sprite::move(step);
12073 }
12074
12075 81360 return enemy::animate(index);
12076 83320 }
12077
12078 81408 bool eTrap2::trapmove(int32_t ndir)
12079 {
12080
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 79530 times.
81408 if(tmpscr->flags2&fFLOATTRAPS)
12081 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
12082
12083 79530 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
12084 81408 }
12085
12086 79605 bool eTrap2::clip()
12087 {
12088
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 23387 times.
✓ Branch 2 taken 23376 times.
✓ Branch 3 taken 16303 times.
✓ Branch 4 taken 16539 times.
79605 switch(dir)
12089 {
12090 case up:
12091
1/2
✓ Branch 0 taken 23387 times.
✗ Branch 1 not taken.
23387 if(y<=0) return true;
12092
12093 23387 break;
12094
12095 case down:
12096
1/2
✓ Branch 0 taken 23376 times.
✗ Branch 1 not taken.
23376 if(y>=160) return true;
12097
12098 23376 break;
12099
12100 case left:
12101
1/2
✓ Branch 0 taken 16303 times.
✗ Branch 1 not taken.
16303 if(x<=0) return true;
12102
12103 16303 break;
12104
12105 case right:
12106
1/2
✓ Branch 0 taken 16539 times.
✗ Branch 1 not taken.
16539 if(x>=240) return true;
12107
12108 16539 break;
12109 }
12110
12111 79605 return false;
12112 79605 }
12113
12114 83330 void eTrap2::draw(BITMAP *dest)
12115 {
12116 83330 update_enemy_frame();
12117 83330 enemy::draw(dest);
12118 83330 }
12119
12120 526 int32_t eTrap2::takehit(weapon*,weapon*)
12121 {
12122 526 return 0;
12123 }
12124
12125 416 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12126 416 {
12127 //do not show "enemy appering" anim -DD
12128 208 clk=0;
12129 208 mainguy=false;
12130 208 clk2=-14;
12131 //Enemy Editor Size Tab
12132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
208 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12133 208 else hxofs = -2;
12134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
208 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12135 208 else hyofs = -2;
12136
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
12137 208 else hxsz = 20;
12138
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
12139 208 else hysz=20;
12140
12141
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
208 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12142
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
208 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12143
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
12144
1/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
12145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
208 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12146 {
12147 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12148 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12149 }
12150
12151
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
12152 //nets+1640;
12153 208 }
12154
12155 71521 bool eRock::animate(int32_t index)
12156 {
12157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71521 times.
71521 if(switch_hooked) return enemy::animate(index);
12158
2/4
✓ Branch 0 taken 71521 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 71521 times.
71521 if(fallclk||drownclk) return enemy::animate(index);
12159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71521 times.
71521 if(dying)
12160 return Dead(index);
12161
12162
2/2
✓ Branch 0 taken 66484 times.
✓ Branch 1 taken 5037 times.
71521 if(clk==0)
12163 {
12164 5037 removearmos(x,y,ffcactivated);
12165 5037 }
12166
12167
2/2
✓ Branch 0 taken 71119 times.
✓ Branch 1 taken 402 times.
71521 if(++clk2==0) // start it
12168 {
12169 402 x=zc_oldrand()&0xF0;
12170 402 y=0;
12171 402 clk3=0;
12172 402 clk2=zc_oldrand()&15;
12173 402 }
12174
12175
2/2
✓ Branch 0 taken 13144 times.
✓ Branch 1 taken 58377 times.
71521 if(clk2>16) // move it
12176 {
12177
2/2
✓ Branch 0 taken 56364 times.
✓ Branch 1 taken 2013 times.
58377 if(clk3<=0) // start bounce
12178 {
12179 2013 dir=zc_oldrand()&1;
12180
12181
2/2
✓ Branch 0 taken 1784 times.
✓ Branch 1 taken 229 times.
2013 if(x<32) dir=1;
12182
12183
2/2
✓ Branch 0 taken 1847 times.
✓ Branch 1 taken 166 times.
2013 if(x>208) dir=0;
12184 2013 }
12185
12186
2/2
✓ Branch 0 taken 56499 times.
✓ Branch 1 taken 1878 times.
58377 if(clk3<13+16)
12187 {
12188 56499 x += dir ? 1 : -1; //right, left
12189 56499 dummy_int[1]=dir;
12190
12191
2/2
✓ Branch 0 taken 4021 times.
✓ Branch 1 taken 52478 times.
56499 if(clk3<2)
12192 {
12193 4021 y-=2; //up
12194 4021 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12195 4021 }
12196
2/2
✓ Branch 0 taken 5996 times.
✓ Branch 1 taken 46482 times.
52478 else if(clk3<5)
12197 {
12198 5996 y--; //up
12199 5996 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12200 5996 }
12201
2/2
✓ Branch 0 taken 5959 times.
✓ Branch 1 taken 40523 times.
46482 else if(clk3<8)
12202 {
12203 5959 dummy_int[2]=(dummy_int[1]==1)?right:left;
12204 5959 }
12205
2/2
✓ Branch 0 taken 5911 times.
✓ Branch 1 taken 34612 times.
40523 else if(clk3<11)
12206 {
12207 5911 y++; //down
12208 5911 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12209 5911 }
12210 else
12211 {
12212 34612 y+=2; //down
12213 34612 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12214 }
12215
12216 56499 ++clk3;
12217 56499 }
12218
2/2
✓ Branch 0 taken 1627 times.
✓ Branch 1 taken 251 times.
1878 else if(y<176)
12219 1627 clk3=0; // next bounce
12220 else
12221 251 clk2 = -(zc_oldrand()&63); // back to top
12222 58377 }
12223
12224 71521 return enemy::animate(index);
12225 71521 }
12226
12227 14169 void eRock::drawshadow(BITMAP *dest, bool translucent)
12228 {
12229
2/2
✓ Branch 0 taken 1822 times.
✓ Branch 1 taken 12347 times.
14169 if(clk2>=0)
12230 {
12231 12347 int32_t tempy=yofs;
12232 12347 flip = 0;
12233 12347 int32_t fdiv = frate/4;
12234
1/2
✓ Branch 0 taken 12347 times.
✗ Branch 1 not taken.
12347 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
12235
1/2
✓ Branch 0 taken 12347 times.
✗ Branch 1 not taken.
12347 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
12236 12347 efrate:((clk>=(frate>>1))?1:0);
12237 12347 shadowtile = wpnsbuf[spr_shadow].tile+f2;
12238
12239 12347 yofs+=8;
12240
5/6
✓ Branch 0 taken 5808 times.
✓ Branch 1 taken 6539 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12347 times.
✓ Branch 4 taken 5808 times.
✓ Branch 5 taken 6539 times.
12347 yofs+=zc_max(0,zc_min(29-clk3,clk3));
12241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12347 times.
12347 if(!shadow_overpit(this))
12242 12347 enemy::drawshadow(dest, translucent);
12243 12347 yofs=tempy;
12244 12347 }
12245 14169 }
12246
12247 71582 void eRock::draw(BITMAP *dest)
12248 {
12249
4/6
✓ Branch 0 taken 9822 times.
✓ Branch 1 taken 61760 times.
✓ Branch 2 taken 9822 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9822 times.
71582 if(clk2>=0 || fallclk||drownclk)
12250 {
12251 61760 int32_t tempdir=dir;
12252 61760 dir=dummy_int[2];
12253 61760 update_enemy_frame();
12254 61760 enemy::draw(dest);
12255 61760 dir=tempdir;
12256 61760 }
12257 71582 }
12258
12259 718 int32_t eRock::takehit(weapon*,weapon*)
12260 {
12261 718 return 0;
12262 }
12263
12264 60 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12265 60 {
12266 30 clk=0;
12267 30 mainguy=false;
12268 30 clk2=-14;
12269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12270 30 else hxofs= -10;
12271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12272 30 else hyofs=-10;
12273
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
12274 30 else hxsz=36;
12275
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
12276 30 else hysz=36;
12277
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
12278 30 else hzsz=16; //can't be jumped
12279
12280
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12281
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12282
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
12283
1/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
12284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12285 {
12286 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12287 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12288 }
12289
12290
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
12291 //nets+1680;
12292 30 }
12293
12294 4440 bool eBoulder::animate(int32_t index)
12295 {
12296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
12297
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
12298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
12299 return Dead(index);
12300
12301
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
12302 {
12303 290 removearmos(x,y,ffcactivated);
12304 290 }
12305
12306 zfix *vert;
12307
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & FLAG_USE_FAKE_Z) ? &fakez : get_bit(quest_rules,qr_ENEMIESZAXIS) ? &z : &y;
12308
12309
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
12310 {
12311 32 x=zc_oldrand()&0xF0;
12312 32 y=-32;
12313 32 clk3=0;
12314 32 clk2=zc_oldrand()&15;
12315 32 }
12316
12317
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
12318 {
12319
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
12320 {
12321 131 dir=zc_oldrand()&1;
12322
12323
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
12324
12325
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
12326 131 }
12327
12328
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
12329 {
12330 3487 x += dir ? 1 : -1; //right, left
12331 3487 dummy_int[1]=dir;
12332
12333
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
12334 {
12335 261 y-=2; //up
12336 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12337 261 }
12338
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
12339 {
12340 382 y--; //up
12341 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12342 382 }
12343
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
12344 {
12345 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
12346 376 }
12347
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
12348 {
12349 367 y++; //down
12350 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12351 367 }
12352 else
12353 {
12354 2101 y+=2; //down
12355 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12356 }
12357
12358 3487 ++clk3;
12359 3487 }
12360
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
12361 101 clk3=0; // next bounce
12362 else
12363 10 clk2 = -(zc_oldrand()&63); // back to top
12364 3598 }
12365
12366 4440 return enemy::animate(index);
12367 4440 }
12368
12369 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
12370 {
12371
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
12372 {
12373 3868 int32_t tempy=yofs;
12374 3868 flip = 0;
12375 3868 int32_t f2=((clk<<2)/frate)<<1;
12376 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
12377
5/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3868 times.
✓ Branch 4 taken 1729 times.
✓ Branch 5 taken 2139 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
12378
12379 3868 yofs+=8;
12380 3868 xofs-=8;
12381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
12382 3868 enemy::drawshadow(dest, translucent);
12383 3868 xofs+=16;
12384 3868 ++shadowtile;
12385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
12386 3868 enemy::drawshadow(dest, translucent);
12387 3868 yofs+=16;
12388 3868 shadowtile+=20;
12389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
12390 3868 enemy::drawshadow(dest, translucent);
12391 3868 xofs-=16;
12392 3868 --shadowtile;
12393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
12394 3868 enemy::drawshadow(dest, translucent);
12395 3868 xofs+=8;
12396 3868 yofs=tempy;
12397 3868 }
12398 4440 }
12399
12400 4440 void eBoulder::draw(BITMAP *dest)
12401 {
12402
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
12403 {
12404 3868 int32_t tempdir=dir;
12405 3868 dir=dummy_int[2];
12406 3868 update_enemy_frame();
12407 3868 dir=tempdir;
12408 3868 xofs-=8;
12409 3868 yofs-=8;
12410 3868 drawblock(dest,15);
12411 3868 xofs+=8;
12412 3868 yofs+=8;
12413 // enemy::draw(dest);
12414 3868 }
12415 4440 }
12416
12417 int32_t eBoulder::takehit(weapon*,weapon*)
12418 {
12419 return 0;
12420 }
12421
12422 4202 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
12423
3/4
✓ Branch 0 taken 2101 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 514 times.
✓ Branch 3 taken 1587 times.
2101 minRange(get_bit(quest_rules, qr_BROKENSTATUES) ? 0 : Clk)
12424 4202 {
12425 /* fixing
12426 hp=1;
12427 */
12428 2101 mainguy=false;
12429
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2094 times.
2101 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12430 2101 hclk=clk; // the "no fire" range
12431 2101 clk=0;
12432 2101 clk3=96;
12433 2101 timer=0;
12434
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2094 times.
2101 if(o_tile==0)
12435 {
12436 2094 superman=1;
12437 2094 hxofs=1000;
12438 2094 }
12439 2101 SIZEflags = d->SIZEflags;
12440
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2101 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2101 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12441 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12442 // al_trace("Enemy txsz:%i\n", txsz);
12443
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2101 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2101 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12444
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2101 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2101 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12445
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2101 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2101 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12446
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2101 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2101 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12447
1/2
✓ Branch 0 taken 2101 times.
✗ Branch 1 not taken.
2101 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12448
1/2
✓ Branch 0 taken 2101 times.
✗ Branch 1 not taken.
2101 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12449 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12450
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2101 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2101 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2101 times.
2101 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12452 {
12453 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12454 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12455 }
12456
12457
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2101 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2101 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12458 2101 }
12459
12460 1497551 bool eProjectile::animate(int32_t index)
12461 {
12462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1497551 times.
1497551 if(switch_hooked) return enemy::animate(index);
12463
2/4
✓ Branch 0 taken 1497551 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1497551 times.
1497551 if(fallclk||drownclk) return enemy::animate(index);
12464
2/2
✓ Branch 0 taken 1490371 times.
✓ Branch 1 taken 7180 times.
1497551 if(clk==0)
12465 {
12466 7180 removearmos(x,y,ffcactivated);
12467 7180 }
12468
12469 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12470 1497551 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12471
12472
4/4
✓ Branch 0 taken 491096 times.
✓ Branch 1 taken 1006455 times.
✓ Branch 2 taken 269087 times.
✓ Branch 3 taken 222009 times.
1497551 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
12473 {
12474 222009 dir=down;
12475 222009 }
12476
4/4
✓ Branch 0 taken 818144 times.
✓ Branch 1 taken 457398 times.
✓ Branch 2 taken 269087 times.
✓ Branch 3 taken 549057 times.
1275542 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
12477 {
12478 549057 dir=right;
12479 549057 }
12480
4/4
✓ Branch 0 taken 502901 times.
✓ Branch 1 taken 223584 times.
✓ Branch 2 taken 269087 times.
✓ Branch 3 taken 233814 times.
726485 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
12481 {
12482 233814 dir=up;
12483 233814 }
12484 else
12485 {
12486 492671 dir=left;
12487 }
12488
12489
3/4
✓ Branch 0 taken 1497551 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 782550 times.
✓ Branch 3 taken 715001 times.
1497551 if(!stunclk && ++clk3>80)
12490 {
12491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 715001 times.
715001 if(dmisc1==9) // Breath type
12492 {
12493 if(timer==0)
12494 {
12495 unsigned r=zc_oldrand();
12496
12497 if(!(r&63))
12498 {
12499 timer=zc_oldrand()%50+50;
12500 }
12501 }
12502
12503 if(timer>0)
12504 {
12505 if(timer%4==0)
12506 {
12507 FireBreath(false);
12508 }
12509
12510 if(--timer==0)
12511 {
12512 clk3=0;
12513 }
12514 }
12515 }
12516
12517 else // Not breath type
12518 {
12519 715001 unsigned r=zc_oldrand();
12520
12521
4/4
✓ Branch 0 taken 11187 times.
✓ Branch 1 taken 703814 times.
✓ Branch 2 taken 834 times.
✓ Branch 3 taken 10353 times.
715001 if(!(r&63) && !HeroInRange(minRange))
12522 {
12523 10353 FireWeapon();
12524
12525
3/4
✓ Branch 0 taken 7982 times.
✓ Branch 1 taken 2371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52 times.
10405 if(get_bit(quest_rules, qr_BROKENSTATUES)==0 &&
12526
3/4
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 7930 times.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
7982 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
12527 {
12528
2/2
✓ Branch 0 taken 7526 times.
✓ Branch 1 taken 456 times.
7982 if(!((r>>7)&15))
12529 {
12530 456 x-=4;
12531 456 FireWeapon();
12532 456 x+=4;
12533 456 }
12534 7982 }
12535
12536 10353 clk3=0;
12537 10353 }
12538 }
12539 715001 }
12540
12541 1497551 return enemy::animate(index);
12542 1497551 }
12543
12544 1503130 void eProjectile::draw(BITMAP *dest)
12545 {
12546 1503130 update_enemy_frame();
12547 1503130 enemy::draw(dest);
12548 1503130 }
12549
12550 46 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12551 46 {
12552 23 hxofs=1000;
12553 23 }
12554
12555 4492 void eTrigger::draw(BITMAP *dest)
12556 {
12557 4492 update_enemy_frame();
12558 4492 enemy::draw(dest);
12559 4492 }
12560
12561 void eTrigger::death_sfx()
12562 {
12563 //silent death
12564 }
12565
12566 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12567 {
12568 o_tile+=wpnsbuf[iwNPCs].tile;
12569 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12570 SIZEflags = d->SIZEflags;
12571 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12572 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12573 // al_trace("Enemy txsz:%i\n", txsz);
12574 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12575 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12576 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12577 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12578 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12579 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12580 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12581 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12582 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12583 {
12584 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12585 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12586 }
12587
12588 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12589 }
12590
12591 bool eNPC::animate(int32_t index)
12592 {
12593 if(switch_hooked) return enemy::animate(index);
12594 if(dying)
12595 return Dead(index);
12596
12597 if(clk==0)
12598 {
12599 removearmos(x,y,ffcactivated);
12600 }
12601
12602 switch(dmisc2)
12603 {
12604 case 0:
12605 {
12606 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12607 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12608
12609 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
12610 {
12611 dir=down;
12612 }
12613
12614 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
12615 {
12616 dir=right;
12617 }
12618 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
12619 {
12620 dir=up;
12621 }
12622 else
12623 {
12624 dir=left;
12625 }
12626 }
12627 break;
12628
12629 case 1:
12630 halting_walk(rate, homing, 0, hrate, 48);
12631
12632 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
12633 {
12634 newdir(rate, homing, 0);
12635 clk2=48;
12636 ++misc;
12637 }
12638
12639 if(clk2==0)
12640 misc=0;
12641
12642 break;
12643 }
12644
12645 return enemy::animate(index);
12646 }
12647
12648 void eNPC::draw(BITMAP *dest)
12649 {
12650 update_enemy_frame();
12651 enemy::draw(dest);
12652 }
12653
12654 int32_t eNPC::takehit(weapon*,weapon*)
12655 {
12656 return 0;
12657 }
12658
12659 188 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12660 188 {
12661
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
12662 {
12663 94 o_tile=clk;
12664 94 cs=id>>12;
12665 94 }
12666
12667 94 id=id&0xFFF;
12668 94 clk=0;
12669
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
12670 94 mainguy=false;
12671 94 SIZEflags = d->SIZEflags;
12672
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12673 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12674 // al_trace("Enemy txsz:%i\n", txsz);
12675
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12676
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12677
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12678
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12679
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12680
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12681 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12682
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12684 {
12685 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12686 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12687 }
12688
12689
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12690 94 }
12691
12692 81 void eSpinTile::facehero()
12693 {
12694
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
12695 {
12696
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
12697 1 dir = up;
12698 else
12699 dir = down;
12700 1 }
12701 else
12702 {
12703 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12704 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12705
12706
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
12707 {
12708 12 dir=l_down;
12709 12 }
12710
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
12711 {
12712 1 dir=down;
12713 1 }
12714
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
12715 {
12716 12 dir=r_down;
12717 12 }
12718
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
12719 {
12720 6 dir=right;
12721 6 }
12722
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
12723 {
12724 17 dir=r_up;
12725 17 }
12726
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
12727 {
12728 8 dir=up;
12729 8 }
12730
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
12731 {
12732 6 dir=l_up;
12733 6 }
12734 else
12735 {
12736 18 dir=left;
12737 }
12738 }
12739 81 }
12740
12741
12742 15539 bool eSpinTile::animate(int32_t index)
12743 {
12744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
12745
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
12746
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
12747 {
12748 1152 return Dead(index);
12749 }
12750
12751
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
12752 {
12753 1241 removearmos(x,y,ffcactivated);
12754 1241 }
12755
12756 14387 ++misc;
12757
12758
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
12759 {
12760 81 facehero();
12761 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12762 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
12763 81 angular=true;
12764 81 angle=ddir;
12765 81 step=zslongToFix(dstep*100);
12766 81 }
12767
12768
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
12769 52 kickbucket();
12770
12771 14387 sprite::move(step);
12772 14387 return enemy::animate(index);
12773 15539 }
12774
12775 15457 void eSpinTile::draw(BITMAP *dest)
12776 {
12777 15457 update_enemy_frame();
12778 15457 y-=(misc>>4);
12779 15457 yofs+=2;
12780 15457 enemy::draw(dest);
12781 15457 yofs-=2;
12782 15457 y+=(misc>>4);
12783 15457 }
12784
12785 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
12786 {
12787 15457 flip = 0;
12788 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
12789 15457 yofs+=4;
12790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
12791 15457 enemy::drawshadow(dest, translucent);
12792 15457 yofs-=4;
12793 15457 }
12794
12795 2960 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
12796 2960 {
12797 //these are here to bypass compiler warnings about unused arguments
12798 1480 Clk=Clk;
12799 1480 mainguy=false;
12800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1480 times.
1480 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12801 /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))]))
12802 {
12803 clk=1;
12804 }*/
12805 //nets+880;
12806 1480 SIZEflags = d->SIZEflags;
12807
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1480 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12808 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12809 // al_trace("Enemy txsz:%i\n", txsz);
12810
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1480 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12811
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1480 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12812
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1480 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12813
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1480 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12814
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12815
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12816 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12817
1/4
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1480 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1480 times.
1480 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12819 {
12820 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12821 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12822 }
12823
12824
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1480 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1480 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12825 1480 }
12826
12827 371492 void eZora::facehero()
12828 {
12829
2/2
✓ Branch 0 taken 6205 times.
✓ Branch 1 taken 365287 times.
371492 if(Hero.x-x==0)
12830 {
12831 6205 dir=(Hero.y+8<y)?up:down;
12832 6205 }
12833 else
12834 {
12835 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12836 365287 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12837
12838
4/4
✓ Branch 0 taken 76242 times.
✓ Branch 1 taken 289045 times.
✓ Branch 2 taken 28788 times.
✓ Branch 3 taken 47454 times.
365287 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
12839 {
12840 47454 dir=l_down;
12841 47454 }
12842
4/4
✓ Branch 0 taken 54307 times.
✓ Branch 1 taken 263526 times.
✓ Branch 2 taken 28788 times.
✓ Branch 3 taken 25519 times.
317833 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
12843 {
12844 25519 dir=down;
12845 25519 }
12846
4/4
✓ Branch 0 taken 73753 times.
✓ Branch 1 taken 218561 times.
✓ Branch 2 taken 28788 times.
✓ Branch 3 taken 44965 times.
292314 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
12847 {
12848 44965 dir=r_down;
12849 44965 }
12850
4/4
✓ Branch 0 taken 98242 times.
✓ Branch 1 taken 149107 times.
✓ Branch 2 taken 28788 times.
✓ Branch 3 taken 69454 times.
247349 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
12851 {
12852 69454 dir=right;
12853 69454 }
12854
4/4
✓ Branch 0 taken 78596 times.
✓ Branch 1 taken 99299 times.
✓ Branch 2 taken 28788 times.
✓ Branch 3 taken 49808 times.
177895 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
12855 {
12856 49808 dir=r_up;
12857 49808 }
12858
4/4
✓ Branch 0 taken 51731 times.
✓ Branch 1 taken 76356 times.
✓ Branch 2 taken 28788 times.
✓ Branch 3 taken 22943 times.
128087 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
12859 {
12860 22943 dir=up;
12861 22943 }
12862
4/4
✓ Branch 0 taken 71427 times.
✓ Branch 1 taken 33717 times.
✓ Branch 2 taken 42639 times.
✓ Branch 3 taken 28788 times.
105144 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
12863 {
12864 42639 dir=l_up;
12865 42639 }
12866 else
12867 {
12868 62505 dir=left;
12869 }
12870 }
12871 371492 }
12872
12873 518888 bool eZora::animate(int32_t index)
12874 {
12875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 518888 times.
518888 if(switch_hooked) return enemy::animate(index);
12876
2/2
✓ Branch 0 taken 1854 times.
✓ Branch 1 taken 517034 times.
518888 if(dying)
12877 1854 return Dead(index);
12878
12879
2/2
✓ Branch 0 taken 513668 times.
✓ Branch 1 taken 3366 times.
517034 if(clk==0)
12880 {
12881 3366 removearmos(x,y,ffcactivated);
12882 3366 }
12883
12884
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 517003 times.
517034 if(watch)
12885 {
12886 31 ++clock_zoras[id];
12887 31 return true;
12888 }
12889
12890
2/2
✓ Branch 0 taken 145511 times.
✓ Branch 1 taken 371492 times.
517003 if(get_bit(quest_rules,qr_NEWENEMYTILES))
12891 {
12892 371492 facehero();
12893 371492 }
12894
12895
6/6
✓ Branch 0 taken 3115 times.
✓ Branch 1 taken 2995 times.
✓ Branch 2 taken 2516 times.
✓ Branch 3 taken 502796 times.
✓ Branch 4 taken 3686 times.
✓ Branch 5 taken 1895 times.
517003 switch(clk)
12896 {
12897 case 0: // reposition him
12898 {
12899 3686 int32_t t=0;
12900 3686 int32_t pos2=zc_oldrand()%160 + 16;
12901 3686 bool placed=false;
12902
12903
4/4
✓ Branch 0 taken 3663 times.
✓ Branch 1 taken 19588 times.
✓ Branch 2 taken 12559 times.
✓ Branch 3 taken 3366 times.
23251 while(!placed && t<160)
12904 {
12905 12559 int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7));
12906
5/6
✓ Branch 0 taken 4056 times.
✓ Branch 1 taken 8503 times.
✓ Branch 2 taken 4056 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 314 times.
✓ Branch 5 taken 3343 times.
16216 if(watertype && ((editorflags & ENEMY_FLAG6) ||
12907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4056 times.
4056 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
12908
3/4
✓ Branch 0 taken 4056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3657 times.
✓ Branch 3 taken 3657 times.
4056 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
12909 {
12910 3343 x=(pos2&15)<<4;
12911 3343 y=pos2&0xF0;
12912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3343 times.
3343 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
12913 3343 hxofs=1000; // avoid hit detection
12914 3343 stunclk=0;
12915 3343 placed=true;
12916 3343 }
12917
12918 19873 pos2+=19;
12919
12920
2/2
✓ Branch 0 taken 17252 times.
✓ Branch 1 taken 2313 times.
19873 if(pos2>=176)
12921 2313 pos2-=160;
12922
12923 19565 ++t;
12924 }
12925
12926
3/4
✓ Branch 0 taken 3343 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3343 times.
3366 if(!placed || whistleclk>=88) // can't place him, he's gone
12927 23 return true;
12928
12929 }
12930 3343 break;
12931
12932 case 35:
12933
2/2
✓ Branch 0 taken 2243 times.
✓ Branch 1 taken 872 times.
3115 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
12934 {
12935 872 dir=(Hero.y+8<y)?up:down;
12936 872 }
12937
12938 3115 hxofs=0;
12939 3115 break;
12940
12941 case 35+19:
12942 2995 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
12943 2995 sfx(wpnsfx(wpn),pan(int32_t(x)));
12944 2995 break;
12945
12946 case 35+66:
12947 2516 hxofs=1000;
12948 2516 break;
12949
12950 case 198:
12951 1895 clk=-1;
12952 1895 break;
12953 }
12954
12955 516660 return enemy::animate(index);
12956 518568 }
12957
12958 518965 void eZora::draw(BITMAP *dest)
12959 {
12960
2/2
✓ Branch 0 taken 10035 times.
✓ Branch 1 taken 508930 times.
518965 if(clk<3)
12961 10035 return;
12962
12963 508930 update_enemy_frame();
12964 508930 enemy::draw(dest);
12965 518965 }
12966
12967 bool eZora::isSubmerged() const
12968 {
12969 return ( clk < 3 );
12970 }
12971
12972
4/8
✓ Branch 0 taken 20980 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20980 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20980 times.
✗ Branch 7 not taken.
62940 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12973 41960 {
12974 20980 multishot= timer = fired = dashing = 0;
12975 20980 hashero = false;
12976 20980 dummy_bool[0]=false;
12977 20980 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
12978
5/6
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 20845 times.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 72 times.
✓ Branch 5 taken 63 times.
20980 if(dmisc9==e9tARMOS && zc_oldrand()&1)
12979 {
12980
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 step=zslongToFix(dmisc10*100);
12981
12982
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 60 times.
72 if(anim==aARMOS4) o_tile+=20;
12983 72 }
12984
12985
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 20845 times.
20980 if(flags & guy_fadeflicker)
12986 {
12987 135 clk=0;
12988 135 superman = 1;
12989 135 fading=fade_flicker;
12990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12991 135 dir=down;
12992
12993
4/6
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 61 times.
✓ Branch 5 taken 74 times.
135 if(!canmove(down,(zfix)8,spw_none,false))
12994
3/6
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 61 times.
✗ Branch 5 not taken.
61 clk3=int32_t(13.0/step);
12995 135 }
12996
1/2
✓ Branch 0 taken 20845 times.
✗ Branch 1 not taken.
20845 else if(flags & guy_fadeinstant)
12997 {
12998 clk=0;
12999 }
13000
13001
1/2
✓ Branch 0 taken 20980 times.
✗ Branch 1 not taken.
20980 shadowdistance = 0;
13002 20980 clk4 = clk5 = 0;
13003 //nets+2380;
13004 20980 SIZEflags = d->SIZEflags;
13005
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 20980 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
20980 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13006 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13007 // al_trace("Enemy txsz:%i\n", txsz);
13008
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 20980 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
20980 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13009
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20980 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20980 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
13010
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20980 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20980 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
13011
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20980 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20980 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13012
1/2
✓ Branch 0 taken 20980 times.
✗ Branch 1 not taken.
20980 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13013
1/2
✓ Branch 0 taken 20980 times.
✗ Branch 1 not taken.
20980 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13014 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13015
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20980 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20980 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20980 times.
20980 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13017 {
13018 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13019 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13020 }
13021
13022
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20980 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20980 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13023 20980 }
13024
13025 8226262 bool eStalfos::animate(int32_t index)
13026 {
13027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8226262 times.
8226262 if(switch_hooked) return enemy::animate(index);
13028
3/4
✓ Branch 0 taken 8226120 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8226120 times.
8226262 if(fallclk||drownclk)
13029 {
13030 142 return enemy::animate(index);
13031 }
13032
2/2
✓ Branch 0 taken 183338 times.
✓ Branch 1 taken 8042782 times.
8226120 if(dying)
13033 {
13034
2/2
✓ Branch 0 taken 183308 times.
✓ Branch 1 taken 30 times.
183338 if(hashero)
13035 {
13036 30 Hero.setEaten(0);
13037 30 hashero=false;
13038 30 }
13039
13040
10/14
✓ Branch 0 taken 17024 times.
✓ Branch 1 taken 166314 times.
✓ Branch 2 taken 1140 times.
✓ Branch 3 taken 15884 times.
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 1091 times.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 49 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 49 times.
183338 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
13041 {
13042 49 hp=-1000;
13043
5/10
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
49 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
13044 49 Ewpns.add(ew);
13045 49 ew->fakez = fakez;
13046
13047
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
49 if(wpn==ewSBomb || wpn==ewBomb)
13048 {
13049 49 ew->step=0;
13050 49 ew->id=wpn;
13051 49 ew->misc=50;
13052 49 ew->clk=48;
13053 49 }
13054
13055 49 fired=true;
13056 49 }
13057
6/6
✓ Branch 0 taken 87078 times.
✓ Branch 1 taken 96211 times.
✓ Branch 2 taken 70876 times.
✓ Branch 3 taken 16202 times.
✓ Branch 4 taken 70858 times.
✓ Branch 5 taken 18 times.
183289 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
13058 {
13059
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
13060 {
13061 1 int32_t wpn2 = wpn+dmisc3;
13062
13063
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
13064 {
13065 wpn2=wpn;
13066 }
13067
13068 1 dummy_bool[0]=true;
13069 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
13070 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13071 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
13072 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13073 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
13074 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13075 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
13076 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13077 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
13078 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13079 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
13080 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13081 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
13082 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13083 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
13084 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13085 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
13086 1 }
13087 18 }
13088
13089 183338 KillWeapon();
13090 183338 return Dead(index);
13091 }
13092 //vire split
13093 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
13094 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
13095
13/14
✓ Branch 0 taken 10365 times.
✓ Branch 1 taken 8032417 times.
✓ Branch 2 taken 10365 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✓ Branch 5 taken 10216 times.
✓ Branch 6 taken 721580 times.
✓ Branch 7 taken 7321053 times.
✓ Branch 8 taken 720373 times.
✓ Branch 9 taken 1207 times.
✓ Branch 10 taken 3931 times.
✓ Branch 11 taken 716442 times.
✓ Branch 12 taken 706 times.
✓ Branch 13 taken 3225 times.
8042782 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
13096 {
13097 855 stop_bgsfx(index);
13098 855 int32_t kids = guys.Count();
13099 855 int32_t id2=dmisc3;
13100
2/2
✓ Branch 0 taken 1696 times.
✓ Branch 1 taken 855 times.
2551 for(int32_t i=0; i < dmisc4; i++)
13101 {
13102 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
13103
4/6
✓ Branch 0 taken 448 times.
✓ Branch 1 taken 1248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1696 times.
1696 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
13104 1696 ((enemy*)guys.spr(kids+i))->count_enemy = false;
13105 1696 }
13106
13107
1/2
✓ Branch 0 taken 855 times.
✗ Branch 1 not taken.
855 if(itemguy) // Hand down the carried item
13108 {
13109 guycarryingitem = guys.Count()-1;
13110 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13111 itemguy = false;
13112 }
13113
13114
1/2
✓ Branch 0 taken 855 times.
✗ Branch 1 not taken.
855 if(hashero)
13115 {
13116 Hero.setEaten(0);
13117 hashero=false;
13118 }
13119
13120
4/4
✓ Branch 0 taken 841 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 706 times.
✓ Branch 3 taken 135 times.
855 if(deadsfx > 0 && dmisc2==e2tSPLIT)
13121 135 sfx(deadsfx,pan(int32_t(x)));
13122
13123 855 return true;
13124 }
13125 /*
13126 else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z
13127 {
13128 stop_bgsfx(index);
13129 int32_t kids = guys.Count();
13130 int32_t id2=dmisc3;
13131
13132 for(int32_t i=0; i < dmisc4; i++)
13133 {
13134 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
13135 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4)))
13136 ((enemy*)guys.spr(kids+i))->count_enemy = false;
13137 }
13138
13139 if(itemguy) // Hand down the carried item
13140 {
13141 guycarryingitem = guys.Count()-1;
13142 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13143 itemguy = false;
13144 }
13145
13146 if(hashero)
13147 {
13148 Hero.setEaten(0);
13149 hashero=false;
13150 }
13151
13152 return true;
13153 }
13154 */
13155
2/2
✓ Branch 0 taken 10435 times.
✓ Branch 1 taken 8031492 times.
8041927 if(fading)
13156 {
13157
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 10241 times.
10435 if(++clk4 > 60)
13158 {
13159 194 clk4=0;
13160 194 superman=0;
13161 194 fading=0;
13162
13163
4/6
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 135 times.
194 if(flags2&cmbflag_armos && z==0 && fakez == 0)
13164 {
13165 //if a custom size (not 16px by 16px)
13166
13167 //if a custom size (not 16px by 16px)
13168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 if (ffcactivated)
13169 removearmosffc(ffcactivated-1);
13170 else
13171 {
13172
4/8
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 135 times.
135 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
13173 {
13174 //zprint("spawn big enemy from armos\n");
13175 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
13176 for(int32_t dx = 0; dx < tysz; dx ++)
13177 {
13178 for(int32_t dy = 0; dy < tysz; dy++)
13179 {
13180 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
13181 did_armos = false;
13182 }
13183 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
13184 did_armos = false;
13185 }
13186 for(int32_t dy = 0; dy < tysz; dy ++)
13187 {
13188 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
13189 did_armos = false;
13190 }
13191 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
13192 }
13193 135 else removearmos(x,y);
13194 }
13195 /*
13196 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
13197 {
13198 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
13199 for(int32_t dx = 0; dx < hxsz; dx += 16)
13200 {
13201 for(int32_t dy = 0; dy < hysz; dy += 16)
13202 {
13203 removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated);
13204 did_armos = false;
13205 }
13206 removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
13207 did_armos = false;
13208 }
13209 for(int32_t dy = 0; dy < hysz; dy += 16)
13210 {
13211 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated);
13212 did_armos = false;
13213 }
13214 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
13215 }
13216 else removearmos(x,y,ffcactivated);
13217 */
13218
13219 135 }
13220
13221 194 clk2=0;
13222
13223 194 newdir();
13224 194 }
13225 10241 else return enemy::animate(index);
13226 194 }
13227
6/8
✓ Branch 0 taken 30924 times.
✓ Branch 1 taken 8000568 times.
✓ Branch 2 taken 30924 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30924 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 28959 times.
✓ Branch 7 taken 1965 times.
8031492 else if(flags2&cmbflag_armos && z==0 && fakez == 0 && clk==0)
13228 1965 removearmos(x,y,ffcactivated);
13229
13230
13231
2/2
✓ Branch 0 taken 2470 times.
✓ Branch 1 taken 8029216 times.
8031686 if(hashero)
13232 {
13233 2470 Hero.setX(x);
13234 2470 Hero.setY(y);
13235 2470 ++clk2;
13236
13237
4/4
✓ Branch 0 taken 957 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 2419 times.
✓ Branch 3 taken 51 times.
2470 if(clk2==(dmisc8==0 ? 95 : dmisc8))
13238 {
13239
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
51 switch(dmisc7)
13240 {
13241 case e7tEATITEMS:
13242 {
13243
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i=0; i<MAXITEMS; i++)
13244 {
13245
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 1 times.
256 if(itemsbuf[i].flags&ITEM_EDIBLE)
13246 1 game->set_item(i, false);
13247 256 }
13248
13249 1 break;
13250 }
13251
13252 case e7tEATMAGIC:
13253 game->change_dmagic(-1*game->get_magicdrainrate());
13254 break;
13255
13256 case e7tEATRUPEES:
13257 game->change_drupy(-1);
13258 break;
13259 }
13260
13261 51 clk2=0;
13262 51 }
13263
13264
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 2285 times.
2470 if((clk&0x18)==8) // stop its animation on the middle frame
13265 2285 --clk;
13266 2470 }
13267
4/4
✓ Branch 0 taken 606776 times.
✓ Branch 1 taken 7422440 times.
✓ Branch 2 taken 353283 times.
✓ Branch 3 taken 253493 times.
8029216 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
13268 {
13269 // Movement engine
13270
4/6
✓ Branch 0 taken 411360 times.
✓ Branch 1 taken 7364363 times.
✓ Branch 2 taken 2211 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7362152 times.
✗ Branch 5 not taken.
7775723 if(clk>=0) switch(id>>12)
13271 {
13272 case 0: // Normal movement
13273
13274 /*
13275 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
13276 {
13277 // Overloading clk4 (Tribble clock) here...
13278 step=17/100.0;
13279 if(clk4<32) misc=1;
13280 else if(clk4<48) misc=2;
13281 else if(clk4<300) { misc=3; step = dstep/100.0; }
13282 else if(clk4<316) misc=2;
13283 else if(clk4<412) misc=1;
13284 else if(clk4<540) { misc=0; step=0; }
13285 else clk4=0;
13286 if(clk4==48) clk=0;
13287 hxofs=(misc>=2)?0:1000;
13288 if (dmisc9==e9tLEEVER)
13289 variable_walk(rate, homing, 0);
13290 else
13291 variable_walk_8(rate, homing, 4, 0);
13292 break;
13293 }
13294 */
13295
4/4
✓ Branch 0 taken 7197952 times.
✓ Branch 1 taken 164200 times.
✓ Branch 2 taken 259462 times.
✓ Branch 3 taken 6938490 times.
7362152 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
13296 {
13297 423662 vire_hop();
13298 423662 break;
13299 }
13300
2/2
✓ Branch 0 taken 506054 times.
✓ Branch 1 taken 6432436 times.
6938490 else if(dmisc9==e9tROPE) //Rope charge
13301 {
13302
9/10
✓ Branch 0 taken 488632 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 72102 times.
✓ Branch 3 taken 416530 times.
✓ Branch 4 taken 65381 times.
✓ Branch 5 taken 6721 times.
✓ Branch 6 taken 64665 times.
✓ Branch 7 taken 716 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 64665 times.
506054 if(!fired && dashing && !stunclk && !watch && !frozenclock)
13303 {
13304
5/6
✓ Branch 0 taken 2372 times.
✓ Branch 1 taken 62293 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2357 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
64665 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
13305 {
13306
13307
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if ( get_bit(quest_rules,qr_BOMBCHUSUPERBOMB) )
13308 {
13309 14 hp=-1000;
13310
13311
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
13312 {
13313
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
13314 14 Ewpns.add(ew);
13315 14 ew->fakez = fakez;
13316
13317
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
13318 {
13319 14 ew->step=0;
13320 14 ew->id=wpn+dmisc3;
13321 14 ew->misc=50;
13322 14 ew->clk=48;
13323 14 }
13324
13325 14 fired=true;
13326 14 }
13327 else
13328 {
13329 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
13330 Ewpns.add(ew);
13331 ew->fakez = fakez;
13332
13333 if(wpn==ewSBomb || wpn==ewBomb)
13334 {
13335 ew->step=0;
13336 ew->id=wpn;
13337 ew->misc=50;
13338 ew->clk=48;
13339 }
13340
13341 fired=true;
13342 }
13343 14 }
13344
13345 else
13346 {
13347 1 hp=-1000;
13348
13349 int32_t wpn2;
13350
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
13351 1 wpn2=wpn;
13352 else
13353 wpn2=wpn;
13354
13355
5/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
1 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
13356 1 Ewpns.add(ew);
13357 1 ew->fakez = fakez;
13358
13359
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(wpn2==ewSBomb || wpn2==ewBomb)
13360 {
13361 1 ew->step=0;
13362 1 ew->id=wpn2;
13363 1 ew->misc=50;
13364 1 ew->clk=48;
13365 1 }
13366
13367 1 fired=true;
13368 }
13369 15 }
13370 64665 }
13371
13372 506054 charge_attack();
13373 506054 break;
13374 }
13375 /*
13376 * Boomerang-throwers have a halt count of 1
13377 * Zols have a halt count of (zc_oldrand()&7)<<4
13378 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
13379 * Everything else has 48
13380 */
13381 else
13382 {
13383
2/2
✓ Branch 0 taken 328834 times.
✓ Branch 1 taken 6103602 times.
6432436 if(wpn==ewBrang) // Goriya
13384 {
13385 328834 halting_walk(rate,homing,0,hrate, 1);
13386 328834 }
13387
4/4
✓ Branch 0 taken 6072543 times.
✓ Branch 1 taken 31059 times.
✓ Branch 2 taken 2324097 times.
✓ Branch 3 taken 3748446 times.
6103602 else if(dmisc9==e9tNORMAL && wpn==0)
13388 {
13389
2/2
✓ Branch 0 taken 518424 times.
✓ Branch 1 taken 3230022 times.
3748446 if(dmisc2==e2tSPLITHIT) // Zol
13390 {
13391 518424 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
13392 518424 }
13393
4/4
✓ Branch 0 taken 1106781 times.
✓ Branch 1 taken 2123241 times.
✓ Branch 2 taken 1022683 times.
✓ Branch 3 taken 84098 times.
3230022 else if(frate<=8 && starting_hp==1) // Gel
13394 {
13395 84098 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
13396 84098 }
13397 else // Other
13398 {
13399 3145924 halting_walk(rate,homing,0,hrate, 48);
13400 }
13401 3748446 }
13402 else // Other
13403 {
13404 2355156 halting_walk(rate,homing,0,hrate, 48);
13405 }
13406 }
13407
13408 //if not in midair, and Hero's swinging sword is nearby, jump.
13409 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
13410 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
13411 {
13412 facehero(false);
13413 sclk=16+((dir^1)<<8);
13414 fall=-FEATHERJUMP;
13415 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
13416 }*/
13417 6432436 break;
13418
13419 // Following cases are for just after creation-by-splitting.
13420 case 1:
13421
2/2
✓ Branch 0 taken 1661 times.
✓ Branch 1 taken 550 times.
2211 if(misc==1)
13422 {
13423 550 dir=up;
13424 550 step=8;
13425 550 }
13426
13427
2/2
✓ Branch 0 taken 529 times.
✓ Branch 1 taken 1682 times.
2211 if(misc<=2)
13428 {
13429 1682 move(step);
13430
13431
2/2
✓ Branch 0 taken 1362 times.
✓ Branch 1 taken 320 times.
1682 if(!canmove(dir,(zfix)0,0,false))
13432 320 dir=down;
13433 1682 }
13434
13435
2/2
✓ Branch 0 taken 1682 times.
✓ Branch 1 taken 529 times.
2211 if(misc==3)
13436 {
13437
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 335 times.
529 if(canmove(right,(zfix)16,0,false))
13438 335 x+=16;
13439 529 }
13440
13441 2211 ++misc;
13442 2211 break;
13443
13444 case 2:
13445 if(misc==1)
13446 {
13447 dir=down;
13448 step=8;
13449 }
13450
13451 if(misc<=2)
13452 {
13453 move(step);
13454 /*
13455 if(!canmove(dir,(zfix)0,0,false))
13456 dir=up;
13457 */
13458 }
13459
13460 if(misc==3)
13461 {
13462 if(canmove(left,(zfix)16,0,false))
13463 x-=16;
13464 }
13465
13466 ++misc;
13467 break;
13468
13469 default:
13470 if(misc==1)
13471 {
13472 dir=(zc_oldrand()%4);
13473 step=8;
13474 }
13475
13476 if(misc<=2)
13477 {
13478 move(step);
13479
13480 if(!canmove(dir,(zfix)0,0,false))
13481 dir=dir^1;
13482 }
13483
13484 if(misc==3)
13485 {
13486 if(dir >= left && canmove(dir,(zfix)16,0,false))
13487 x+=(dir==left ? -16 : 16);
13488 }
13489
13490 ++misc;
13491 break;
13492 7364363 }
13493
13494
4/4
✓ Branch 0 taken 15749 times.
✓ Branch 1 taken 7759974 times.
✓ Branch 2 taken 15220 times.
✓ Branch 3 taken 529 times.
7775723 if(id>>12 && misc>=4) //recently spawned by a split enemy
13495 {
13496 529 id&=0xFFF;
13497 529 step = zslongToFix(dstep*100);
13498
13499
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if(x<32) x=32;
13500
13501
2/2
✓ Branch 0 taken 519 times.
✓ Branch 1 taken 10 times.
529 if(x>208) x=208;
13502
13503
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 17 times.
529 if(y<32) y=32;
13504
13505
2/2
✓ Branch 0 taken 524 times.
✓ Branch 1 taken 5 times.
529 if(y>128) y=128;
13506
13507 529 misc=3;
13508 529 }
13509 7775723 }
13510 else
13511 {
13512 //sfx(wpnsfx(wpn),pan(int32_t(x)));
13513
1/2
✓ Branch 0 taken 253493 times.
✗ Branch 1 not taken.
253493 if(clk2>2) clk2--;
13514 }
13515
13516 // Fire Zol
13517
7/8
✓ Branch 0 taken 3215269 times.
✓ Branch 1 taken 4816417 times.
✓ Branch 2 taken 6634 times.
✓ Branch 3 taken 3208635 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 6587 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 47 times.
8031686 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
13518 {
13519 47 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
13520 47 sfx(wpnsfx(wpn),pan(int32_t(x)));
13521
13522 47 int32_t i=Ewpns.Count()-1;
13523 47 weapon *ew = (weapon*)(Ewpns.spr(i));
13524
13525
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
13526 {
13527 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
13528 if ( ew->do_animation ) ew->tile+=ew->aframe;
13529 }
13530 47 }
13531 // Goriya
13532
14/16
✓ Branch 0 taken 606776 times.
✓ Branch 1 taken 7424863 times.
✓ Branch 2 taken 277413 times.
✓ Branch 3 taken 329363 times.
✓ Branch 4 taken 270503 times.
✓ Branch 5 taken 6910 times.
✓ Branch 6 taken 248066 times.
✓ Branch 7 taken 22437 times.
✓ Branch 8 taken 248066 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 245360 times.
✓ Branch 11 taken 2706 times.
✓ Branch 12 taken 245360 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 241742 times.
✓ Branch 15 taken 3618 times.
8031639 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
13533 {
13534 3618 misc=index+100;
13535
7/14
✓ Branch 0 taken 3618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3618 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3618 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3618 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3618 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3618 times.
✗ Branch 13 not taken.
3618 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
13536 3618 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
13537
13538
2/2
✓ Branch 0 taken 3463 times.
✓ Branch 1 taken 155 times.
3618 if(dmisc1==2)
13539 {
13540 155 int32_t ndir=dir;
13541
13542
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 151 times.
155 if(Hero.x-x==0)
13543 {
13544 4 ndir=(Hero.y+8<y)?up:down;
13545 4 }
13546 else //turn to face Hero
13547 {
13548 double _MSVC2022_tmp1, _MSVC2022_tmp2;
13549 151 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
13550
13551
4/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 9 times.
151 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
13552 {
13553 9 ndir=down;
13554 9 }
13555
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 41 times.
142 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
13556 {
13557 41 ndir=right;
13558 41 }
13559
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 33 times.
101 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
13560 {
13561 33 ndir=up;
13562 33 }
13563 else
13564 {
13565 68 ndir=left;
13566 }
13567 }
13568
13569 155 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
13570
13571
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 153 times.
155 if(canmove(ndir,false))
13572 {
13573 153 dir=ndir;
13574 153 }
13575 155 }
13576 3618 }
13577
15/16
✓ Branch 0 taken 7996792 times.
✓ Branch 1 taken 31229 times.
✓ Branch 2 taken 107212 times.
✓ Branch 3 taken 7920809 times.
✓ Branch 4 taken 94077 times.
✓ Branch 5 taken 13135 times.
✓ Branch 6 taken 79370 times.
✓ Branch 7 taken 14707 times.
✓ Branch 8 taken 78713 times.
✓ Branch 9 taken 657 times.
✓ Branch 10 taken 73384 times.
✓ Branch 11 taken 5329 times.
✓ Branch 12 taken 73384 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 72440 times.
8028021 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
13578
3/3
✓ Branch 0 taken 13553 times.
✓ Branch 1 taken 57986 times.
✓ Branch 2 taken 901 times.
72440 switch(dmisc1)
13579 {
13580 case e1tCONSTANT: //Deathnut
13581 {
13582 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
13583
2/2
✓ Branch 0 taken 56772 times.
✓ Branch 1 taken 1214 times.
57986 if(clk5>64)
13584 {
13585 1214 clk5=0;
13586 1214 fired=false;
13587 1214 }
13588
13589 57986 clk5+=(zc_oldrand()&3);
13590
13591
4/4
✓ Branch 0 taken 35670 times.
✓ Branch 1 taken 22316 times.
✓ Branch 2 taken 12082 times.
✓ Branch 3 taken 23588 times.
57986 if((clk5>24)&&(clk5<52))
13592 {
13593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23588 times.
23588 if ( do_animation )tile+=20; //firing
13594
13595
4/4
✓ Branch 0 taken 12909 times.
✓ Branch 1 taken 10679 times.
✓ Branch 2 taken 11601 times.
✓ Branch 3 taken 1308 times.
23588 if(!fired&&(clk5>=38))
13596 {
13597
5/10
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1308 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1308 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1308 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1308 times.
✗ Branch 9 not taken.
1308 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
13598 1308 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
13599 1308 sfx(wpnsfx(wpn),pan(int32_t(x)));
13600 1308 fired=true;
13601 1308 }
13602 23588 }
13603
13604 57986 break;
13605 }
13606
13607 case e1tFIREOCTO: //Fire Octo
13608 901 timer=zc_oldrand()%50+50;
13609 901 break;
13610
13611 default:
13612 13553 FireWeapon();
13613 13553 break;
13614 72440 }
13615
13616 /* Fire again if:
13617 * - clk2 about to run out
13618 * - not already double-firing (dmisc1 is 1)
13619 * - not carrying Hero
13620 * - one in 0xF chance
13621 */
13622
8/10
✓ Branch 0 taken 306669 times.
✓ Branch 1 taken 7725017 times.
✓ Branch 2 taken 2695 times.
✓ Branch 3 taken 303974 times.
✓ Branch 4 taken 2695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 181 times.
✓ Branch 9 taken 2514 times.
8031686 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
13623 {
13624 #if 1
13625 181 newdir(rate, homing, grumble);
13626 #else
13627 dir^=2;
13628 #endif
13629 181 clk2=28;
13630 181 ++multishot;
13631 181 }
13632
13633
2/2
✓ Branch 0 taken 1966071 times.
✓ Branch 1 taken 6065615 times.
8031686 if(clk2==0)
13634 {
13635 6065615 multishot = 0;
13636 6065615 }
13637
13638
2/2
✓ Branch 0 taken 7967569 times.
✓ Branch 1 taken 64117 times.
8031686 if(timer) //Fire Octo
13639 {
13640 64117 clk2=15; //this keeps the octo in place until he's done firing
13641
13642
2/2
✓ Branch 0 taken 48413 times.
✓ Branch 1 taken 15704 times.
64117 if(!(timer%4))
13643 {
13644 15704 FireBreath(false);
13645 15704 }
13646
13647 64117 --timer;
13648 64117 }
13649
13650
2/2
✓ Branch 0 taken 7856292 times.
✓ Branch 1 taken 175394 times.
8031686 if(dmisc2==e2tTRIBBLE)
13651 175394 ++clk4;
13652
13653
7/10
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 8029446 times.
✓ Branch 2 taken 605 times.
✓ Branch 3 taken 8031081 times.
✓ Branch 4 taken 605 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 605 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 605 times.
8031686 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
13654 {
13655 605 int32_t kids = guys.Count();
13656 605 int32_t id2=dmisc3;
13657
13658
2/2
✓ Branch 0 taken 605 times.
✓ Branch 1 taken 605 times.
1210 for(int32_t i=0; i<dmisc4; i++)
13659 {
13660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 605 times.
605 if(addenemy(x,y,id2,-24))
13661 {
13662
1/2
✓ Branch 0 taken 605 times.
✗ Branch 1 not taken.
605 if(itemguy) // Hand down the carried item
13663 {
13664 guycarryingitem = guys.Count()-1;
13665 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13666 itemguy = false;
13667 }
13668
13669 605 ((enemy*)guys.spr(kids+i))->count_enemy = false;
13670 605 }
13671 605 }
13672
13673
1/2
✓ Branch 0 taken 605 times.
✗ Branch 1 not taken.
605 if(hashero)
13674 {
13675 Hero.setEaten(0);
13676 hashero=false;
13677 }
13678
13679 605 stop_bgsfx(index);
13680 605 return true;
13681 }
13682
13683 8031081 return enemy::animate(index);
13684 8226262 }
13685
13686 8534418 void eStalfos::draw(BITMAP *dest)
13687 {
13688 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged
13689 {
13690 clk4--; //Kludge
13691 return;
13692 }*/
13693
13694 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1)
13695 {
13696 cs = dcset;
13697 }*/
13698 8534418 update_enemy_frame();
13699
13700
7/8
✓ Branch 0 taken 8534276 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 8534276 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35975 times.
✓ Branch 5 taken 8498301 times.
✓ Branch 6 taken 33085 times.
✓ Branch 7 taken 2890 times.
8534418 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
13701 {
13702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if ( do_animation )tile+=20;
13703 2890 }
13704
13705 8534418 enemy::draw(dest);
13706 8534418 }
13707
13708 1933775 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
13709 {
13710 1933775 int32_t tempy=yofs;
13711
13712 /*
13713 if (clk6 && dir>=left && !get_bit(quest_rules,qr_ENEMIESZAXIS)) {
13714 flip = 0;
13715 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
13716 (clk/(frate/4)):((clk>=(frate>>1))?1:0);
13717 shadowtile = wpnsbuf[spr_shadow].tile+f2;
13718 yofs+=(((int32_t)y+17)&0xF0)-y;
13719 yofs+=8;
13720 }
13721 */
13722
3/4
✓ Branch 0 taken 1853002 times.
✓ Branch 1 taken 80773 times.
✓ Branch 2 taken 1933775 times.
✗ Branch 3 not taken.
1933775 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_bit(quest_rules,qr_ENEMIESZAXIS))
13723 {
13724 flip = 0;
13725 int32_t fdiv = frate/4;
13726 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13727
13728 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
13729 efrate:((clk>=(frate>>1))?1:0);
13730 shadowtile = wpnsbuf[spr_shadow].tile;
13731
13732 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13733 {
13734 shadowtile+=f2;
13735 }
13736 else
13737 {
13738 shadowtile+=f2?1:0;
13739 }
13740
13741 yofs+=shadowdistance;
13742 yofs+=8;
13743 }
13744
3/4
✓ Branch 0 taken 1853002 times.
✓ Branch 1 taken 80773 times.
✓ Branch 2 taken 1933775 times.
✗ Branch 3 not taken.
1933775 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_bit(quest_rules,qr_POLVIRE_NO_SHADOW))
13745 {
13746 flip = 0;
13747 int32_t fdiv = frate/4;
13748 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13749
13750 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
13751 efrate:((clk>=(frate>>1))?1:0);
13752 shadowtile = wpnsbuf[spr_shadow].tile;
13753
13754 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13755 {
13756 shadowtile+=f2;
13757 }
13758 else
13759 {
13760 shadowtile+=f2?1:0;
13761 }
13762 }
13763
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 1933633 times.
1933775 if(!shadow_overpit(this))
13764 1933633 enemy::drawshadow(dest, translucent);
13765 1933775 yofs=tempy;
13766 1933775 }
13767
13768 85343 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
13769 {
13770 85343 int32_t wpnId = w->id;
13771 85343 int32_t wpnDir = w->dir;
13772
13773
4/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 85166 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 122 times.
85343 if(wpnId==wHammer && shield && (flags & guy_bkshield)
13774
5/8
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 19 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 19 times.
55 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
13775
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
19 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
13776 {
13777 36 shield = false;
13778 36 flags &= ~(inv_left|inv_right|inv_back|inv_front);
13779
13780
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 22 times.
36 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
13781 14 o_tile=s_tile;
13782 36 }
13783
13784 85343 int32_t ret = enemy::takehit(w,realweap);
13785
13786
4/4
✓ Branch 0 taken 10524 times.
✓ Branch 1 taken 74819 times.
✓ Branch 2 taken 9363 times.
✓ Branch 3 taken 1161 times.
85343 if(sclk && dmisc2==e2tSPLITHIT)
13787 1161 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
13788
13789 85343 return ret;
13790 }
13791
13792 506054 void eStalfos::charge_attack()
13793 {
13794
2/2
✓ Branch 0 taken 4772 times.
✓ Branch 1 taken 501282 times.
506054 if(slide())
13795 4772 return;
13796
13797
9/12
✓ Branch 0 taken 501282 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 501282 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 485334 times.
✓ Branch 5 taken 15948 times.
✓ Branch 6 taken 467597 times.
✓ Branch 7 taken 17737 times.
✓ Branch 8 taken 463431 times.
✓ Branch 9 taken 4166 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 463431 times.
501282 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
13798 37851 return;
13799
13800
2/2
✓ Branch 0 taken 18575 times.
✓ Branch 1 taken 444856 times.
463431 if(clk3<=0)
13801 {
13802 18575 fix_coords(true);
13803
13804
2/2
✓ Branch 0 taken 5236 times.
✓ Branch 1 taken 13339 times.
18575 if(!dashing)
13805 {
13806 13339 int32_t ldir = lined_up(7,false);
13807
13808
4/4
✓ Branch 0 taken 1319 times.
✓ Branch 1 taken 12020 times.
✓ Branch 2 taken 1125 times.
✓ Branch 3 taken 194 times.
13339 if(ldir!=-1 && canmove(ldir,false))
13809 {
13810 1125 dir=ldir;
13811 1125 dashing=true;
13812 1125 step=zslongToFix(dstep*100)+1;
13813 1125 }
13814 12214 else newdir(4,0,0);
13815 13339 }
13816
13817
2/2
✓ Branch 0 taken 17896 times.
✓ Branch 1 taken 679 times.
18575 if(!canmove(dir,false))
13818 {
13819 679 step=zslongToFix(dstep*100);
13820 679 newdir();
13821 679 dashing=false;
13822 679 }
13823
13824 18575 zfix div = step;
13825
13826
1/2
✓ Branch 0 taken 18575 times.
✗ Branch 1 not taken.
18575 if(div == 0)
13827 div = 1;
13828
13829 18575 clk3=(int32_t)(16.0/div);
13830 18575 return;
13831 }
13832
13833 444856 move(step);
13834 444856 --clk3;
13835 506054 }
13836
13837 423662 void eStalfos::vire_hop()
13838 {
13839 //if ( sclk > 0 ) return; //Don't hop during knockback.
13840
13841 // if(dmisc9!=e9tPOLSVOICE)
13842 // {
13843 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
13844 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
13845 // return; //the enemy should split if it is sliding!
13846 // //else sclk=0; //might need this here, too. -Z
13847 // }
13848
2/2
✓ Branch 0 taken 164200 times.
✓ Branch 1 taken 259462 times.
423662 if(dmisc9!=e9tPOLSVOICE)
13849 {
13850
2/2
✓ Branch 0 taken 159048 times.
✓ Branch 1 taken 5152 times.
164200 if(sclk!=0)
13851 {
13852
2/2
✓ Branch 0 taken 1309 times.
✓ Branch 1 taken 3843 times.
5152 if (dmisc2==e2tSPLITHIT) return;
13853 //return;
13854 3843 }
13855 162891 }
13856 259462 else sclk=0;
13857
13858
8/12
✓ Branch 0 taken 422353 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 422353 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 414783 times.
✓ Branch 5 taken 7570 times.
✓ Branch 6 taken 401087 times.
✓ Branch 7 taken 13696 times.
✓ Branch 8 taken 401087 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 401087 times.
422353 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
13859 21266 return;
13860
13861 401087 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
13862 401087 int32_t jump_height = (dmisc9==e9tPOLSVOICE) ? 27 : 16;
13863
13864 401087 y=floor_y;
13865
13866
2/2
✓ Branch 0 taken 387843 times.
✓ Branch 1 taken 13244 times.
401087 if(clk3<=0)
13867 {
13868 13244 fix_coords();
13869
13870 //z=0;
13871 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
13872 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
13873
9/10
✓ Branch 0 taken 2722 times.
✓ Branch 1 taken 10522 times.
✓ Branch 2 taken 2407 times.
✓ Branch 3 taken 315 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 2313 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
13244 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV)))) //Vires in old quests
13874 10931 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
13875
13876
2/2
✓ Branch 0 taken 2722 times.
✓ Branch 1 taken 10522 times.
13244 if(clk2<=0)
13877 {
13878 //z=0;
13879
6/6
✓ Branch 0 taken 9602 times.
✓ Branch 1 taken 920 times.
✓ Branch 2 taken 9364 times.
✓ Branch 3 taken 238 times.
✓ Branch 4 taken 6679 times.
✓ Branch 5 taken 2685 times.
10522 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
13880 {
13881
13882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7837 times.
7837 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
13883 /*if (dmisc9==e9tPOLSVOICE )
13884 {
13885 zprint2("polsvoice jump_width is: %d\n", jump_width);
13886 zprint2("polsvoice raw step is: %d\n", step);
13887 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
13888 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
13889 }
13890 else
13891 {
13892 zprint2("vire jump_width is: %d\n", jump_width);
13893 zprint2("vire raw step is: %d\n", step);
13894 zprint2("vire step.getInt() is: %d\n", step.getInt());
13895 zprint2("setting clk2 on vire to: %d\n", clk2);
13896 }
13897 */
13898 7837 }
13899 10522 }
13900
13901
4/4
✓ Branch 0 taken 5111 times.
✓ Branch 1 taken 8133 times.
✓ Branch 2 taken 2342 times.
✓ Branch 3 taken 2769 times.
13244 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
13902 {
13903 2769 clk2=int32_t((16.0*jump_width)/step.getFloat());
13904 2769 }
13905
13906 13244 clk3=int32_t(16.0/step.getFloat());
13907 13244 }
13908
13909 401087 --clk3;
13910
13911
3/4
✓ Branch 0 taken 153155 times.
✓ Branch 1 taken 247932 times.
✓ Branch 2 taken 153155 times.
✗ Branch 3 not taken.
401087 if(dmisc9==e9tPOLSVOICE || clk2>0)
13912 401087 move(step);
13913
13914 401087 floor_y=y;
13915 401087 clk2--;
13916
13917 //if we're in the middle of a jump
13918
6/6
✓ Branch 0 taken 309352 times.
✓ Branch 1 taken 91735 times.
✓ Branch 2 taken 131312 times.
✓ Branch 3 taken 178040 times.
✓ Branch 4 taken 63228 times.
✓ Branch 5 taken 68084 times.
401087 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
13919 {
13920 241268 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
13921
13922
4/4
✓ Branch 0 taken 97084 times.
✓ Branch 1 taken 144184 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 90933 times.
241268 if(get_bit(quest_rules,qr_ENEMIESZAXIS) && !(isSideViewGravity()))
13923 {
13924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90933 times.
90933 if (moveflags & FLAG_USE_FAKE_Z) fakez=h;
13925 90933 else z=h;
13926 90933 }
13927 else
13928 {
13929 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
13930 //y-=h;
13931 150335 y=floor_y-h;
13932 150335 shadowdistance=h;
13933 }
13934 241268 }
13935 else
13936 159819 shadowdistance = 0;
13937 423662 }
13938
13939 49 void eStalfos::eathero()
13940 {
13941
5/8
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 30 times.
49 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
13942 {
13943 30 hashero=true;
13944 30 y=floor_y;
13945 30 z=0;
13946
13947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(Hero.isSwimming())
13948 {
13949 Hero.setX(x);
13950 Hero.setY(y);
13951 }
13952 else
13953 {
13954 30 x=Hero.getX();
13955 30 y=Hero.getY();
13956 }
13957
13958 30 clk2=0;
13959 30 }
13960 49 }
13961
13962 852136 bool eStalfos::WeaponOut()
13963 {
13964
2/2
✓ Branch 0 taken 1539071 times.
✓ Branch 1 taken 356901 times.
1895972 for(int32_t i=0; i<Ewpns.Count(); i++)
13965 {
13966
3/4
✓ Branch 0 taken 495235 times.
✓ Branch 1 taken 1043836 times.
✓ Branch 2 taken 495235 times.
✗ Branch 3 not taken.
1539071 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
13967 {
13968 495235 return true;
13969 }
13970
13971 /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self
13972 stop_sfx(bgsfx);
13973 */
13974 1043836 }
13975
13976 356901 return false;
13977 852136 }
13978
13979 183338 void eStalfos::KillWeapon()
13980 {
13981
2/2
✓ Branch 0 taken 183338 times.
✓ Branch 1 taken 177866 times.
361204 for(int32_t i=0; i<Ewpns.Count(); i++)
13982 {
13983
4/4
✓ Branch 0 taken 149845 times.
✓ Branch 1 taken 28021 times.
✓ Branch 2 taken 149353 times.
✓ Branch 3 taken 492 times.
177866 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
13984 {
13985 //only kill this Goriya's boomerang -DD
13986
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 216 times.
492 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
13987 {
13988 216 Ewpns.del(i);
13989 216 }
13990 492 }
13991 177866 }
13992
13993
4/4
✓ Branch 0 taken 16202 times.
✓ Branch 1 taken 167136 times.
✓ Branch 2 taken 8166 times.
✓ Branch 3 taken 8036 times.
183338 if(wpn==ewBrang && !Ewpns.idCount(ewBrang))
13994 {
13995 8166 stop_sfx(WAV_BRANG);
13996 8166 }
13997 183338 }
13998
13999 void eStalfos::break_shield()
14000 {
14001 if(!shield)
14002 return;
14003
14004 flags&=~(inv_front | inv_back | inv_left | inv_right);
14005 shield=false;
14006
14007 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
14008 o_tile=s_tile;
14009 }
14010
14011 10462 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14012 10462 {
14013
1/2
✓ Branch 0 taken 5231 times.
✗ Branch 1 not taken.
5231 dir=(zc_oldrand()&7)+8;
14014
1/2
✓ Branch 0 taken 5231 times.
✗ Branch 1 not taken.
5231 step=0;
14015 5231 movestatus=1;
14016
3/4
✓ Branch 0 taken 4275 times.
✓ Branch 1 taken 956 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4275 times.
5231 if (dmisc1 != 1 && dmisc19 > 0)
14017 {
14018 step = dmisc19/100.0;
14019 movestatus = 1;
14020 }
14021
1/2
✓ Branch 0 taken 5231 times.
✗ Branch 1 not taken.
5231 if (dmisc1 == 2) movestatus=2;
14022 5231 c=0;
14023 5231 SIZEflags = d->SIZEflags;
14024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5231 times.
5231 if ( !(SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ) hxofs=2;
14025
1/2
✓ Branch 0 taken 5231 times.
✗ Branch 1 not taken.
5231 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
14026
14027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5231 times.
5231 if ( !(SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ) hxsz=12;
14028
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5231 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
14029
14030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5231 times.
5231 if ( !(SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ) hyofs=4;
14031
1/2
✓ Branch 0 taken 5231 times.
✗ Branch 1 not taken.
5231 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14032
14033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5231 times.
5231 if ( !(SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ) hysz=8;
14034
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5231 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
14035
14036
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5231 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14037 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
14038 // al_trace("Enemy txsz:%i\n", txsz);
14039
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5231 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14040
14041
14042
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5231 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
14043
14044
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5231 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
14045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5231 times.
5231 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14046 {
14047 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14048 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14049 }
14050
14051
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5231 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
14052 5231 clk4=0;
14053 //nets;
14054 5231 dummy_int[1]=0;
14055 5231 }
14056
14057 1566150 bool eKeese::animate(int32_t index)
14058 {
14059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1566150 times.
1566150 if(switch_hooked) return enemy::animate(index);
14060
2/4
✓ Branch 0 taken 1566150 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1566150 times.
1566150 if(fallclk||drownclk) return enemy::animate(index);
14061
2/2
✓ Branch 0 taken 58134 times.
✓ Branch 1 taken 1508016 times.
1566150 if(dying)
14062 58134 return Dead(index);
14063
14064
2/2
✓ Branch 0 taken 1499518 times.
✓ Branch 1 taken 8498 times.
1508016 if(clk==0)
14065 {
14066 8498 removearmos(x,y,ffcactivated);
14067 8498 }
14068
14069
2/2
✓ Branch 0 taken 368335 times.
✓ Branch 1 taken 1139681 times.
1508016 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
14070 {
14071 368335 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
14072 368335 }
14073 else
14074 {
14075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1139681 times.
1139681 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
14076 1139681 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
14077 }
14078
14079
2/2
✓ Branch 0 taken 27624 times.
✓ Branch 1 taken 1480392 times.
1508016 if(dmisc2 == e2tKEESETRIB)
14080 {
14081
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27624 times.
✓ Branch 2 taken 27571 times.
✓ Branch 3 taken 53 times.
27624 if(++clk4==(dmisc20>0?dmisc20:256))
14082 {
14083
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 41 times.
53 if(!m_walkflag(x,y,0, dir))
14084 {
14085 41 int32_t kids = guys.Count();
14086 41 bool success = false;
14087 41 int32_t id2=dmisc3;
14088 41 success = 0 != addenemy((zfix)x,(zfix)y,id2,-24);
14089
14090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 if(success)
14091 {
14092
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 if(itemguy) // Hand down the carried item
14093 {
14094 guycarryingitem = guys.Count()-1;
14095 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
14096 itemguy = false;
14097 }
14098
14099 41 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
14100 41 }
14101
14102 41 stop_bgsfx(index);
14103 41 return true;
14104 }
14105 else
14106 {
14107 12 clk4=0;
14108 }
14109 12 }
14110 27583 }
14111 // Keese Tribbles stay on the ground, so there's no problem when they transform.
14112
3/4
✓ Branch 0 taken 483168 times.
✓ Branch 1 taken 997224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 483168 times.
1480392 else if(get_bit(quest_rules,qr_ENEMIESZAXIS) && !(isSideViewGravity()))
14113 {
14114
1/2
✓ Branch 0 taken 483168 times.
✗ Branch 1 not taken.
483168 if (get_bit(quest_rules,qr_OLD_KEESE_Z_AXIS))
14115 {
14116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 483168 times.
483168 if (moveflags & FLAG_USE_FAKE_Z)
14117 {
14118 fakez=int32_t(step/zslongToFix(dstep*100));
14119 // Some variance in keese flight heights when away from Hero
14120 fakez+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-128)/10));
14121
14122 }
14123 else
14124 {
14125 483168 z=int32_t(step/zslongToFix(dstep*100));
14126 // Some variance in keese flight heights when away from Hero
14127
2/2
✓ Branch 0 taken 392397 times.
✓ Branch 1 taken 90771 times.
483168 z+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-128)/10));
14128 }
14129 483168 }
14130 else
14131 {
14132 if (moveflags & FLAG_USE_FAKE_Z)
14133 {
14134 fakez=int32_t(step/zslongToFix(dstep*100));
14135 // Some variance in keese flight heights when away from Hero
14136 fakez+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-40)/4));
14137
14138 }
14139 else
14140 {
14141 z=int32_t(step/zslongToFix(dstep*100));
14142 // Some variance in keese flight heights when away from Hero
14143 z+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-40)/4));
14144 }
14145 }
14146 483168 }
14147
14148 1507975 return enemy::animate(index);
14149 1566150 }
14150
14151 431730 void eKeese::drawshadow(BITMAP *dest, bool translucent)
14152 {
14153 431730 int32_t tempy=yofs;
14154 431730 flip = 0;
14155 431730 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
14156
14157
2/2
✓ Branch 0 taken 155463 times.
✓ Branch 1 taken 276267 times.
431730 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
14158
2/2
✓ Branch 0 taken 302522 times.
✓ Branch 1 taken 129208 times.
431730 if(!get_bit(quest_rules,qr_ENEMIESZAXIS))
14159 {
14160 129208 yofs+=int32_t(step/zslongToFix(dstep*10));
14161 129208 }
14162
14163
6/6
✓ Branch 0 taken 428136 times.
✓ Branch 1 taken 3594 times.
✓ Branch 2 taken 302522 times.
✓ Branch 3 taken 125614 times.
✓ Branch 4 taken 294452 times.
✓ Branch 5 taken 8070 times.
431730 if(!shadow_overpit(this) && (!get_bit(quest_rules,qr_ENEMIESZAXIS) || step > 0))
14164 420066 enemy::drawshadow(dest, translucent);
14165 431730 yofs=tempy;
14166 431730 }
14167
14168 3602286 void eKeese::draw(BITMAP *dest)
14169 {
14170 3602286 update_enemy_frame();
14171 3602286 enemy::draw(dest);
14172 3602286 }
14173
14174 10771 void eWizzrobe::submerge(bool set)
14175 {
14176
2/2
✓ Branch 0 taken 10743 times.
✓ Branch 1 taken 28 times.
10771 if(get_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING))
14177 {
14178 10743 hxofs = set?1000:0;
14179 10743 return;
14180 }
14181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(submerged == set) return;
14182 28 submerged = set;
14183
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(set)
14184 14 hxofs+=1000;
14185 14 else hxofs -= 1000;
14186 10771 }
14187 3588 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14188 3588 {
14189 1794 hxofs = 0;
14190 1794 submerged = false;
14191
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 1086 times.
1794 switch(dmisc1)
14192 {
14193 case 0:
14194
1/2
✓ Branch 0 taken 1086 times.
✗ Branch 1 not taken.
1086 submerge(true);
14195 1086 fading=fade_invisible;
14196 // Set clk to just before the 'reappear' threshold
14197
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1086 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1086 times.
✓ Branch 4 taken 878 times.
✓ Branch 5 taken 208 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 878 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 208 times.
1086 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
14198 1086 break;
14199
14200 default:
14201 708 dir=(loadside==right)?right:left;
14202 708 misc=-3;
14203 708 break;
14204 }
14205
14206 //netst+2880;
14207 1794 charging=false;
14208 1794 firing=false;
14209 1794 fclk=0;
14210
2/2
✓ Branch 0 taken 1086 times.
✓ Branch 1 taken 708 times.
1794 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
14211 1794 SIZEflags = d->SIZEflags;
14212
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1794 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1794 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14213 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
14214 // al_trace("Enemy txsz:%i\n", txsz);
14215
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1794 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1794 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14216
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1794 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1794 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
14217
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1794 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1794 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
14218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1794 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1794 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
14219
1/2
✓ Branch 0 taken 1794 times.
✗ Branch 1 not taken.
1794 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 )
14220 {
14221 hxofs = (submerged?hxofs:0)+d->hxofs;
14222 }
14223
1/2
✓ Branch 0 taken 1794 times.
✗ Branch 1 not taken.
1794 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14224 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
14225
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1794 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1794 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
14226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1794 times.
1794 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14227 {
14228 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14229 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14230 }
14231
14232
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1794 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1794 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
14233 1794 }
14234
14235 896057 bool eWizzrobe::animate(int32_t index)
14236 {
14237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 896057 times.
896057 if(switch_hooked) return enemy::animate(index);
14238
2/4
✓ Branch 0 taken 896057 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 896057 times.
896057 if(fallclk||drownclk) return enemy::animate(index);
14239
2/2
✓ Branch 0 taken 20512 times.
✓ Branch 1 taken 875545 times.
896057 if(dying)
14240 {
14241 20512 return Dead(index);
14242 }
14243
14244
2/2
✓ Branch 0 taken 848762 times.
✓ Branch 1 taken 26783 times.
875545 if(clk==0)
14245 {
14246 26783 removearmos(x,y,ffcactivated);
14247 26783 }
14248
14249
2/2
✓ Branch 0 taken 426011 times.
✓ Branch 1 taken 449534 times.
875545 if(dmisc1) // Floating
14250 {
14251 426011 wizzrobe_attack();
14252 426011 }
14253 else // Teleporting
14254 {
14255
5/6
✓ Branch 0 taken 444181 times.
✓ Branch 1 taken 5353 times.
✓ Branch 2 taken 2710 times.
✓ Branch 3 taken 441471 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2710 times.
449534 if(watch || (!get_bit(quest_rules, qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
14256 {
14257 5353 fading=0;
14258 5353 submerge(false);
14259 5353 solid_update(false);
14260 5353 }
14261
8/8
✓ Branch 0 taken 429448 times.
✓ Branch 1 taken 2624 times.
✓ Branch 2 taken 2292 times.
✓ Branch 3 taken 2217 times.
✓ Branch 4 taken 2180 times.
✓ Branch 5 taken 1890 times.
✓ Branch 6 taken 1822 times.
✓ Branch 7 taken 1708 times.
444181 else switch(clk)
14262 {
14263 case 0:
14264
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 2143 times.
2624 if(!dmisc2)
14265 {
14266 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
14267 // but should not appear on dungeon walls.
14268
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 1916 times.
2143 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
14269
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 1871 times.
1916 else if (editorflags&ENEMY_FLAG5)
14270 {
14271 //2.10 Windrobe
14272 //randomise location and face Hero
14273 45 int32_t t=0;
14274 45 bool placed=false;
14275
14276
4/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 45 times.
96 while(!placed && t<160)
14277 {
14278
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(isdungeon())
14279 {
14280 51 x=((zc_oldrand()%12)+2)*16;
14281 51 y=((zc_oldrand()%7)+2)*16;
14282 51 }
14283 else
14284 {
14285 x=((zc_oldrand()%14)+1)*16;
14286 y=((zc_oldrand()%9)+1)*16;
14287 }
14288
14289
6/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 45 times.
101 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
14290 {
14291 45 placed=true;
14292 45 }
14293
14294 51 ++t;
14295 }
14296
14297
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 31 times.
45 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
14298 {
14299
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 5 times.
14 if(y<Hero.getY())
14300 {
14301 9 dir=down;
14302 9 }
14303 else
14304 {
14305 5 dir=up;
14306 }
14307 14 }
14308 else
14309 {
14310
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 15 times.
31 if(x<Hero.getX())
14311 {
14312 15 dir=right;
14313 15 }
14314 else
14315 {
14316 16 dir=left;
14317 }
14318 }
14319
14320
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!placed) // can't place him, he's gone
14321 return true;
14322
14323
14324 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
14325 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
14326 45 }
14327 1871 else place_on_axis(true, dmisc4!=0);
14328 2143 }
14329 else
14330 {
14331 481 int32_t t=0;
14332 481 bool placed=false;
14333
14334
4/4
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 641 times.
✓ Branch 3 taken 481 times.
1122 while(!placed && t<160)
14335 {
14336
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 17 times.
641 if(isdungeon())
14337 {
14338 624 x=((zc_oldrand()%12)+2)*16;
14339 624 y=((zc_oldrand()%7)+2)*16;
14340 624 }
14341 else
14342 {
14343 17 x=((zc_oldrand()%14)+1)*16;
14344 17 y=((zc_oldrand()%9)+1)*16;
14345 }
14346
14347
6/6
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 554 times.
✓ Branch 2 taken 389 times.
✓ Branch 3 taken 165 times.
✓ Branch 4 taken 160 times.
✓ Branch 5 taken 481 times.
1195 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
14348 {
14349 481 placed=true;
14350 481 }
14351
14352 641 ++t;
14353 }
14354
14355
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 322 times.
481 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
14356 {
14357
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 62 times.
159 if(y<Hero.getY())
14358 {
14359 97 dir=down;
14360 97 }
14361 else
14362 {
14363 62 dir=up;
14364 }
14365 159 }
14366 else
14367 {
14368
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 156 times.
322 if(x<Hero.getX())
14369 {
14370 166 dir=right;
14371 166 }
14372 else
14373 {
14374 156 dir=left;
14375 }
14376 }
14377
14378
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 if(!placed) // can't place him, he's gone
14379 return true;
14380 }
14381
14382 2624 fading=fade_flicker;
14383 2624 submerge(false);
14384 2624 solid_update(false);
14385 2624 break;
14386
14387 case 64:
14388 2292 fading=0;
14389 2292 charging=true;
14390 2292 break;
14391
14392 case 73:
14393 2217 charging=false;
14394 2217 firing=40;
14395 2217 break;
14396
14397 case 83:
14398 2180 wizzrobe_attack_for_real();
14399 2180 break;
14400
14401 case 119:
14402 1890 firing=false;
14403 1890 charging=true;
14404 1890 break;
14405
14406 case 128:
14407 1822 fading=fade_flicker;
14408 1822 charging=false;
14409 1822 break;
14410
14411 case 146:
14412 1708 fading=fade_invisible;
14413 1708 submerge(true);
14414 1708 solid_update(false);
14415
14416 [[fallthrough]];
14417 default:
14418
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 431156 times.
✓ Branch 2 taken 428528 times.
✓ Branch 3 taken 2628 times.
431156 if(clk>=(146+zc_max(0,dmisc5)))
14419 2628 clk=-1;
14420
14421 431156 break;
14422 }
14423 }
14424
14425 875545 return enemy::animate(index);
14426 896057 }
14427
14428 3473 void eWizzrobe::wizzrobe_attack_for_real()
14429 {
14430
1/2
✓ Branch 0 taken 3473 times.
✗ Branch 1 not taken.
3473 if(wpn==0) // Edited enemies
14431 return;
14432
14433
2/2
✓ Branch 0 taken 773 times.
✓ Branch 1 taken 2700 times.
3473 if(dmisc2 == 0) //normal weapon
14434 {
14435 2700 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
14436 2700 sfx(WAV_WAND,pan(int32_t(x)));
14437 2700 }
14438
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 450 times.
773 else if(dmisc2 == 1) // ring of fire
14439 {
14440 323 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
14441 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14442 323 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
14443 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14444 323 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
14445 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14446 323 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
14447 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14448 323 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
14449 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14450 323 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
14451 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14452 323 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
14453 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14454 323 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
14455 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14456 323 sfx(WAV_FIRE,pan(int32_t(x)));
14457
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 283 times.
323 if (get_bit(quest_rules, qr_8WAY_SHOT_SFX)) sfx(WAV_FIRE,pan(int32_t(x)));
14458 else
14459 {
14460
2/18
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 264 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
283 switch(wpn)
14461 {
14462 19 case ewFireball: sfx(40,pan(int32_t(x))); break;
14463
14464 case ewArrow: sfx(1,pan(int32_t(x))); break; //Ghost.zh has 0?
14465 case ewBrang: sfx(4,pan(int32_t(x))); break; //Ghost.zh has 0?
14466 case ewSword: sfx(20,pan(int32_t(x))); break; //Ghost.zh has 0?
14467 case ewRock: sfx(51,pan(int32_t(x))); break;
14468 case ewMagic: sfx(32,pan(int32_t(x))); break;
14469 case ewBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
14470 case ewSBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
14471 case ewLitBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
14472 case ewLitSBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
14473 case ewFireTrail: sfx(13,pan(int32_t(x))); break;
14474 264 case ewFlame: sfx(13,pan(int32_t(x))); break;
14475 case ewWind: sfx(32,pan(int32_t(x))); break;
14476 case ewFlame2: sfx(13,pan(int32_t(x))); break;
14477 case ewFlame2Trail: sfx(13,pan(int32_t(x))); break;
14478 case ewIce: sfx(44,pan(int32_t(x))); break;
14479 case ewFireball2: sfx(40,pan(int32_t(x))); break; //fireball (rising)
14480 default: sfx(WAV_FIRE,pan(int32_t(x))); break;
14481
14482 }
14483 }
14484 323 }
14485
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 14 times.
450 else if(dmisc2==2) // summons specific enemy
14486 {
14487 436 int32_t bc=0;
14488
14489
2/2
✓ Branch 0 taken 5394 times.
✓ Branch 1 taken 436 times.
5830 for(int32_t gc=0; gc<guys.Count(); gc++)
14490 {
14491
2/2
✓ Branch 0 taken 2590 times.
✓ Branch 1 taken 2804 times.
5394 if((((enemy*)guys.spr(gc))->id) == dmisc3)
14492 {
14493 2804 ++bc;
14494 2804 }
14495 5394 }
14496
14497
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 428 times.
436 if(bc<=40)
14498 {
14499 428 int32_t kids = guys.Count();
14500 428 int32_t bats=(zc_oldrand()%3)+1;
14501
14502
2/2
✓ Branch 0 taken 868 times.
✓ Branch 1 taken 428 times.
1296 for(int32_t i=0; i<bats; i++)
14503 {
14504 // Summon bats (or anything)
14505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 868 times.
868 if(addchild(x,y,dmisc3,-10, this->script_UID))
14506 868 ((enemy*)guys.spr(kids+i))->count_enemy = false;
14507 868 }
14508
14509 428 sfx(WAV_FIRE,pan(int32_t(x)));
14510 428 }
14511 436 }
14512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(dmisc2==3) //summon from layer
14513 {
14514
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count_layer_enemies()==0)
14515 {
14516 return;
14517 }
14518
14519 14 int32_t kids = guys.Count();
14520
14521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(kids<200)
14522 {
14523 14 int32_t newguys=(zc_oldrand()%3)+1;
14524 14 bool summoned=false;
14525
14526
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 14 times.
39 for(int32_t i=0; i<newguys; i++)
14527 {
14528 25 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
14529 25 int32_t x2=0;
14530 25 int32_t y2=0;
14531
14532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t k=0; k<20; ++k)
14533 {
14534 27 x2=16*((zc_oldrand()%12)+2);
14535 27 y2=16*((zc_oldrand()%7)+2);
14536
14537
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 25 times.
54 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
14538 {
14539
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(addchild(x2,y2,get_bit(quest_rules,qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
14540 {
14541 25 ((enemy*)guys.spr(kids+i))->count_enemy = false;
14542
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if (get_bit(quest_rules,qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
14543 {
14544 ((enemy*)guys.spr(kids+i))->fakez = 64;
14545 ((enemy*)guys.spr(kids+i))->z = 0;
14546 }
14547 25 }
14548
14549 25 summoned=true;
14550 25 break;
14551 }
14552 2 }
14553 25 }
14554
14555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(summoned)
14556 {
14557 14 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
14558 14 }
14559 14 }
14560 14 }
14561 3473 }
14562
14563
14564 426011 void eWizzrobe::wizzrobe_attack()
14565 {
14566
9/12
✓ Branch 0 taken 414668 times.
✓ Branch 1 taken 11343 times.
✓ Branch 2 taken 414668 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 399557 times.
✓ Branch 5 taken 15111 times.
✓ Branch 6 taken 397406 times.
✓ Branch 7 taken 2151 times.
✓ Branch 8 taken 397406 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 397406 times.
426011 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
14567 28605 return;
14568
14569
3/8
✓ Branch 0 taken 381839 times.
✓ Branch 1 taken 15567 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 381839 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
397406 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
14570 {
14571 15567 fix_coords();
14572
14573
5/5
✓ Branch 0 taken 1781 times.
✓ Branch 1 taken 517 times.
✓ Branch 2 taken 7678 times.
✓ Branch 3 taken 3691 times.
✓ Branch 4 taken 1900 times.
15567 switch(misc)
14574 {
14575 case 1: //walking
14576
2/2
✓ Branch 0 taken 2748 times.
✓ Branch 1 taken 943 times.
3691 if(!m_walkflag(x,y,spw_door, dir))
14577 943 misc=0;
14578 else
14579 {
14580 2748 clk3=16;
14581
14582
2/2
✓ Branch 0 taken 2415 times.
✓ Branch 1 taken 333 times.
2748 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
14583 {
14584 333 wizzrobe_newdir(0);
14585 333 }
14586 }
14587
14588 3691 break;
14589
14590 case 2: //phasing
14591 {
14592 1900 int32_t jx=x;
14593 1900 int32_t jy=y;
14594 1900 int32_t jdir=-1;
14595
14596
5/5
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 240 times.
✓ Branch 2 taken 219 times.
✓ Branch 3 taken 230 times.
✓ Branch 4 taken 240 times.
1900 switch(zc_oldrand()&7)
14597 {
14598 case 0:
14599 240 jx-=32;
14600 240 jy-=32;
14601 240 jdir=15;
14602 240 break;
14603
14604 case 1:
14605 219 jx+=32;
14606 219 jy-=32;
14607 219 jdir=9;
14608 219 break;
14609
14610 case 2:
14611 230 jx+=32;
14612 230 jy+=32;
14613 230 jdir=11;
14614 230 break;
14615
14616 case 3:
14617 240 jx-=32;
14618 240 jy+=32;
14619 240 jdir=13;
14620 240 break;
14621 }
14622
14623
10/10
✓ Branch 0 taken 929 times.
✓ Branch 1 taken 971 times.
✓ Branch 2 taken 820 times.
✓ Branch 3 taken 109 times.
✓ Branch 4 taken 764 times.
✓ Branch 5 taken 56 times.
✓ Branch 6 taken 663 times.
✓ Branch 7 taken 101 times.
✓ Branch 8 taken 537 times.
✓ Branch 9 taken 126 times.
1900 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
14624 {
14625 537 misc=3;
14626 537 clk3=32;
14627 537 dir=jdir;
14628 537 break;
14629 }
14630 1363 }
14631 [[fallthrough]];
14632 case 3:
14633 1880 dir&=3;
14634 1880 misc=0;
14635 [[fallthrough]];
14636 case 0:
14637 9558 wizzrobe_newdir(64);
14638 [[fallthrough]];
14639 default:
14640
2/2
✓ Branch 0 taken 10219 times.
✓ Branch 1 taken 1120 times.
11339 if(!canmove(dir,(zfix)1,spw_door,false))
14641 {
14642
2/2
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 55 times.
1120 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
14643 {
14644 1065 misc=1;
14645 1065 clk3=16;
14646 1065 }
14647 else
14648 {
14649 55 wizzrobe_newdir(64);
14650 55 misc=0;
14651 55 clk3=32;
14652 }
14653 1120 }
14654 else
14655 {
14656 10219 clk3=32;
14657 }
14658
14659 11339 break;
14660 }
14661
14662
2/2
✓ Branch 0 taken 14010 times.
✓ Branch 1 taken 1557 times.
15567 if(misc<0)
14663 1557 ++misc;
14664 15567 }
14665
14666 397406 --clk3;
14667
14668
3/3
✓ Branch 0 taken 76925 times.
✓ Branch 1 taken 289157 times.
✓ Branch 2 taken 31324 times.
397406 switch(misc)
14669 {
14670 case 1:
14671 case 3:
14672 76925 step=1;
14673 76925 break;
14674
14675 case 2:
14676 31324 step=0;
14677 31324 break;
14678
14679 default:
14680 289157 step=0.5;
14681 289157 break;
14682
14683 }
14684
14685 397406 move(step);
14686
14687 // if(d->misc1 && misc<=0 && clk3==28)
14688
5/6
✓ Branch 0 taken 397406 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 289157 times.
✓ Branch 3 taken 108249 times.
✓ Branch 4 taken 279165 times.
✓ Branch 5 taken 9992 times.
397406 if(dmisc1 && misc<=0 && clk3==28)
14689 {
14690
2/2
✓ Branch 0 taken 8544 times.
✓ Branch 1 taken 1448 times.
9992 if(dmisc2 != 1)
14691 {
14692
2/2
✓ Branch 0 taken 7574 times.
✓ Branch 1 taken 970 times.
8544 if(lined_up(8,false) == dir)
14693 {
14694 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
14695 // sfx(WAV_WAND,pan(int32_t(x)));
14696 970 wizzrobe_attack_for_real();
14697 970 fclk=30;
14698 970 }
14699 8544 }
14700 else
14701 {
14702
2/2
✓ Branch 0 taken 1125 times.
✓ Branch 1 taken 323 times.
1448 if((zc_oldrand()%500)>=400)
14703 {
14704 323 wizzrobe_attack_for_real();
14705 323 fclk=30;
14706 323 }
14707 }
14708 9992 }
14709
14710
4/4
✓ Branch 0 taken 254003 times.
✓ Branch 1 taken 143403 times.
✓ Branch 2 taken 1944 times.
✓ Branch 3 taken 252059 times.
397406 if(misc==0 && (zc_oldrand()&127)==0)
14711 1944 misc=2;
14712
14713
4/4
✓ Branch 0 taken 33268 times.
✓ Branch 1 taken 364138 times.
✓ Branch 2 taken 31593 times.
✓ Branch 3 taken 1675 times.
397406 if(misc==2 && clk3==4)
14714 1675 fix_coords();
14715
14716
2/4
✓ Branch 0 taken 397406 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 397406 times.
397406 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
14717 {
14718
2/2
✓ Branch 0 taken 360579 times.
✓ Branch 1 taken 36827 times.
397406 if(fclk>0)
14719 {
14720 36827 --fclk;
14721 36827 }
14722 397406 }
14723
14724 426011 }
14725
14726 9946 void eWizzrobe::wizzrobe_newdir(int32_t homing)
14727 {
14728 // Wizzrobes shouldn't move to the edge of the screen;
14729 // if they're already there, they should move toward the center
14730
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 9942 times.
9946 if(x<32)
14731 4 dir=right;
14732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9942 times.
9942 else if(x>=224)
14733 dir=left;
14734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9942 times.
9942 else if(y<32)
14735 dir=down;
14736
1/2
✓ Branch 0 taken 9942 times.
✗ Branch 1 not taken.
9942 else if(y>=144)
14737 dir=up;
14738 else
14739 9942 newdir(4,homing,spw_wizzrobe);
14740 9946 }
14741
14742 897226 void eWizzrobe::draw(BITMAP *dest)
14743 {
14744 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
14745
13/14
✓ Branch 0 taken 433467 times.
✓ Branch 1 taken 463759 times.
✓ Branch 2 taken 369645 times.
✓ Branch 3 taken 63822 times.
✓ Branch 4 taken 41618 times.
✓ Branch 5 taken 391849 times.
✓ Branch 6 taken 41029 times.
✓ Branch 7 taken 589 times.
✓ Branch 8 taken 40272 times.
✓ Branch 9 taken 757 times.
✓ Branch 10 taken 38408 times.
✓ Branch 11 taken 1864 times.
✓ Branch 12 taken 38408 times.
✗ Branch 13 not taken.
897226 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
14746 38408 return;
14747
14748 858818 int32_t tempint=dummy_int[1];
14749 858818 bool tempbool1=dummy_bool[1];
14750 858818 bool tempbool2=dummy_bool[2];
14751 858818 dummy_int[1]=fclk;
14752 858818 dummy_bool[1]=charging;
14753 858818 dummy_bool[2]=firing;
14754 858818 update_enemy_frame();
14755 858818 dummy_int[1]=tempint;
14756 858818 dummy_bool[1]=tempbool1;
14757 858818 dummy_bool[2]=tempbool2;
14758 858818 enemy::draw(dest);
14759 897226 }
14760
14761 /*********************************/
14762 /********** Bosses ***********/
14763 /*********************************/
14764
14765 246 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14766 246 {
14767 123 fading=fade_flash_die;
14768 //nets+5120;
14769
6/8
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 29 times.
✓ Branch 7 taken 3 times.
123 if(dir==down&&y>=128)
14770 {
14771 3 dir=up;
14772 3 }
14773
14774
5/8
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 86 times.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 37 times.
✗ Branch 7 not taken.
123 if(dir==right&&x>=208)
14775 {
14776 dir=left;
14777 }
14778 123 SIZEflags = d->SIZEflags;
14779
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14780 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
14781 // al_trace("Enemy txsz:%i\n", txsz);
14782
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14783
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
123 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
14784
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
123 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
14785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
123 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
14786
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
14787
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14788 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
14789
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
123 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
14790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14791 {
14792 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14793 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14794 }
14795
14796
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
123 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
14797 123 }
14798
14799 85233 bool eDodongo::animate(int32_t index)
14800 {
14801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85233 times.
85233 if(switch_hooked) return enemy::animate(index);
14802
2/2
✓ Branch 0 taken 3024 times.
✓ Branch 1 taken 82209 times.
85233 if(dying)
14803 {
14804 3024 return Dead(index);
14805 }
14806
14807
2/2
✓ Branch 0 taken 81837 times.
✓ Branch 1 taken 372 times.
82209 if(clk==0)
14808 {
14809 372 removearmos(x,y,ffcactivated);
14810 372 }
14811
14812
2/2
✓ Branch 0 taken 7968 times.
✓ Branch 1 taken 74241 times.
82209 if(clk2) // ate a bomb
14813 {
14814
2/2
✓ Branch 0 taken 7885 times.
✓ Branch 1 taken 83 times.
7968 if(--clk2==0)
14815 83 hp-=misc; // store bomb's power in misc
14816 7968 }
14817 else
14818 74241 constant_walk(rate,homing,spw_clipright);
14819
14820 82209 hxsz = (dir<=down) ? 16 : 32;
14821 // hysz = (dir>=left) ? 16 : 32;
14822
14823 82209 return enemy::animate(index);
14824 85233 }
14825
14826 85223 void eDodongo::draw(BITMAP *dest)
14827 {
14828 85223 tile=o_tile;
14829
14830
2/2
✓ Branch 0 taken 2026 times.
✓ Branch 1 taken 83197 times.
85223 if(clk<0)
14831 {
14832 2026 enemy::drawzcboss(dest);
14833 2026 return;
14834 }
14835
14836 83197 update_enemy_frame();
14837 83197 enemy::drawzcboss(dest);
14838
14839
2/2
✓ Branch 0 taken 33684 times.
✓ Branch 1 taken 49513 times.
83197 if(dummy_int[1]!=0) //additional tiles
14840 {
14841 49513 tile+=dummy_int[1]; //second tile is previous tile
14842 49513 xofs-=16; //new xofs change
14843 49513 enemy::drawzcboss(dest);
14844 49513 xofs+=16;
14845 49513 }
14846
14847 85223 }
14848
14849 5499 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
14850 {
14851 5499 int32_t wpnId = w->id;
14852 5499 int32_t power = w->power;
14853 5499 int32_t wpnx = w->x;
14854 5499 int32_t wpny = w->y;
14855
14856
5/12
✓ Branch 0 taken 5499 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5499 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1602 times.
✓ Branch 5 taken 3897 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1602 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
5499 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
14857 3897 return 0;
14858
14859
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 594 times.
✓ Branch 2 taken 903 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 89 times.
1602 switch(wpnId)
14860 {
14861 case wPhantom:
14862 return 0;
14863
14864 case wFire:
14865 case wBait:
14866 case wWhistle:
14867 case wWind:
14868 case wSSparkle:
14869 case wFSparkle:
14870 return 0;
14871
14872 case wLitBomb:
14873 case wLitSBomb:
14874
6/6
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 392 times.
✓ Branch 2 taken 230 times.
✓ Branch 3 taken 364 times.
✓ Branch 4 taken 511 times.
✓ Branch 5 taken 83 times.
594 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
14875 511 return 0;
14876
14877 83 clk2=96;
14878 83 misc=power;
14879
14880
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 3 times.
83 if(wpnId==wLitSBomb)
14881 3 item_set=isSBOMB100;
14882
14883 83 return 1;
14884
14885 case wBomb:
14886 case wSBomb:
14887
6/6
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 527 times.
✓ Branch 2 taken 257 times.
✓ Branch 3 taken 646 times.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 586 times.
903 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
14888 317 return 0;
14889
14890 586 stunclk=160;
14891 586 misc=wpnId; // store wpnId
14892 586 return 1;
14893
14894 case wSword:
14895
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 58 times.
89 if(stunclk)
14896 {
14897 58 sfx(WAV_EHIT,pan(int32_t(x)));
14898 58 hp=0;
14899 58 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
14900 58 fading=0; // don't flash
14901 58 return 1;
14902 }
14903
14904 [[fallthrough]];
14905 default:
14906 47 sfx(WAV_CHINK,pan(int32_t(x)));
14907 47 }
14908
14909 47 return 1;
14910 5499 }
14911
14912 4 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14913 4 {
14914 2 fading=fade_flash_die;
14915 //nets+5180;
14916 2 previous_dir=-1;
14917
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 if(dir==down&&y>=128)
14918 {
14919 dir=up;
14920 }
14921
14922
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 if(dir==right&&x>=208)
14923 {
14924 dir=left;
14925 }
14926 2 SIZEflags = d->SIZEflags;
14927
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14928 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
14929 // al_trace("Enemy txsz:%i\n", txsz);
14930
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14931
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
14932
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
14933
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
14934
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
14935
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14936 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
14937
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
14938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14939 {
14940 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14941 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14942 }
14943
14944
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
14945 2 }
14946
14947 848 bool eDodongo2::animate(int32_t index)
14948 {
14949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 848 times.
848 if(switch_hooked) return enemy::animate(index);
14950
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 812 times.
848 if(dying)
14951 {
14952 36 return Dead(index);
14953 }
14954
14955
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 4 times.
812 if(clk==0)
14956 {
14957 4 removearmos(x,y,ffcactivated);
14958 4 }
14959
14960
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 620 times.
812 if(clk2) // ate a bomb
14961 {
14962
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 2 times.
192 if(--clk2==0)
14963 2 hp-=misc; // store bomb's power in misc
14964 192 }
14965 else
14966 620 constant_walk(rate,homing,spw_clipbottomright);
14967
14968 812 hxsz = (dir<=down) ? 16 : 32;
14969 812 hysz = (dir>=left) ? 16 : 32;
14970 812 hxofs=(dir>=left)?-8:0;
14971 812 hyofs=(dir<left)?-8:0;
14972
14973 812 return enemy::animate(index);
14974 848 }
14975
14976 848 void eDodongo2::draw(BITMAP *dest)
14977 {
14978
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 818 times.
848 if(clk<0)
14979 {
14980 30 enemy::drawzcboss(dest);
14981 30 return;
14982 }
14983
14984 818 int32_t tempx=xofs;
14985 818 int32_t tempy=yofs;
14986 818 update_enemy_frame();
14987 818 enemy::drawzcboss(dest);
14988 818 tile+=dummy_int[1]; //second tile change
14989 818 xofs+=dummy_int[2]; //new xofs change
14990 818 yofs+=dummy_int[3]; //new yofs change
14991 818 enemy::drawzcboss(dest);
14992 818 xofs=tempx;
14993 818 yofs=tempy;
14994 848 }
14995
14996 165 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
14997 {
14998 165 int32_t wpnId = w->id;
14999 165 int32_t power = w->power;
15000 165 int32_t wpnx = w->x;
15001 165 int32_t wpny = w->y;
15002
15003
5/8
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 145 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
165 if(dying || clk<0 || clk2>0 || superman)
15004 145 return 0;
15005
15006
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
20 switch(wpnId)
15007 {
15008 case wPhantom:
15009 return 0;
15010
15011 case wFire:
15012 case wBait:
15013 case wWhistle:
15014 case wWind:
15015 case wSSparkle:
15016 case wFSparkle:
15017 return 0;
15018
15019 case wLitBomb:
15020 case wLitSBomb:
15021
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 switch(dir)
15022 {
15023 case up:
15024 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
15025 return 0;
15026
15027 break;
15028
15029 case down:
15030 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
15031 return 0;
15032
15033 break;
15034
15035 case left:
15036
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
15037 return 0;
15038
15039 2 break;
15040
15041 case right:
15042 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
15043 return 0;
15044
15045 break;
15046 }
15047
15048 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
15049 // return 0;
15050 2 clk2=96;
15051 2 misc=power;
15052
15053
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(wpnId==wLitSBomb)
15054 item_set=isSBOMB100;
15055
15056 2 return 1;
15057
15058 case wBomb:
15059 case wSBomb:
15060
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
15 switch(dir)
15061 {
15062 case up:
15063 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
15064 return 0;
15065
15066 break;
15067
15068 case down:
15069 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
15070 return 0;
15071
15072 break;
15073
15074 case left:
15075
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
15076 return 0;
15077
15078 15 break;
15079
15080 case right:
15081 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
15082 return 0;
15083
15084 break;
15085 }
15086
15087 15 stunclk=160;
15088 15 misc=wpnId; // store wpnId
15089 15 return 1;
15090
15091 case wSword:
15092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(stunclk)
15093 {
15094 2 sfx(WAV_EHIT,pan(int32_t(x)));
15095 2 hp=0;
15096 2 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
15097 2 fading=0; // don't flash
15098 2 return 1;
15099 }
15100
15101 [[fallthrough]];
15102 default:
15103 1 sfx(WAV_CHINK,pan(int32_t(x)));
15104 1 }
15105
15106 1 return 1;
15107 165 }
15108
15109 142 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
15110 142 {
15111 //these are here to bypass compiler warnings about unused arguments
15112
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 if ( !(editorflags & ENEMY_FLAG5) )
15113 {
15114
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 x = dmisc1 ? 64 : 176;
15115
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 y = 64;
15116 71 }
15117 else { x = X; y = Y; }
15118
15119 //nets+5940;
15120
3/4
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✓ Branch 3 taken 30 times.
71 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15121 {
15122 41 }
15123 else
15124 {
15125
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 23 times.
30 if(dmisc1)
15126 {
15127 7 flip=1;
15128 7 }
15129 }
15130
15131
3/6
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 71 times.
✓ Branch 4 taken 71 times.
✗ Branch 5 not taken.
71 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
15132 71 clk3=32;
15133 71 clk2=0;
15134 71 clk4=clk;
15135 71 dir=left;
15136 71 SIZEflags = d->SIZEflags;
15137
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
71 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15138 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15139 // al_trace("Enemy txsz:%i\n", txsz);
15140
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
71 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15141
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
71 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
15142
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
71 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
15143
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
71 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15144
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15145
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15146 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
71 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15149 {
15150 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
15151 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15152 }
15153
15154
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
71 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15155 71 }
15156
15157 46439 bool eAquamentus::animate(int32_t index)
15158 {
15159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46439 times.
46439 if(switch_hooked) return enemy::animate(index);
15160
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 45255 times.
46439 if(dying)
15161 1184 return Dead(index);
15162
15163 // fbx=x+((id==eRAQUAM)?4:-4);
15164
2/2
✓ Branch 0 taken 45052 times.
✓ Branch 1 taken 203 times.
45255 if(clk==0)
15165 {
15166 203 removearmos(x,y,ffcactivated);
15167 203 }
15168
15169 45255 fbx=x;
15170
15171 /*
15172 if (get_bit(quest_rules,qr_NEWENEMYTILES)&&id==eLAQUAM)
15173 {
15174 fbx+=16;
15175 }
15176 */
15177
2/2
✓ Branch 0 taken 44966 times.
✓ Branch 1 taken 289 times.
45255 if(--clk3==0)
15178 {
15179 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
15180 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
15181 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
15182 289 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
15183 289 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
15184 289 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
15185 289 sfx(wpnsfx(wpn),pan(int32_t(x)));
15186 289 }
15187
15188
4/4
✓ Branch 0 taken 13967 times.
✓ Branch 1 taken 31288 times.
✓ Branch 2 taken 228 times.
✓ Branch 3 taken 13739 times.
45255 if(clk3<-80 && !(zc_oldrand()&63))
15189 {
15190 228 clk3=32;
15191 228 }
15192
15193
2/2
✓ Branch 0 taken 44532 times.
✓ Branch 1 taken 723 times.
45255 if(!((clk4+1)&63))
15194 {
15195 723 int32_t d2=(zc_oldrand()%3)+1;
15196
15197
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 487 times.
723 if(d2>=left)
15198 {
15199 487 dir=d2;
15200 487 }
15201
15202
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 381 times.
723 if(dmisc1)
15203 {
15204
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 34 times.
342 if(x<=40)
15205 {
15206 34 dir=right;
15207 34 }
15208
15209
1/2
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
342 if(x>=104)
15210 {
15211 dir=left;
15212 }
15213 342 }
15214 else
15215 {
15216
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 14 times.
381 if(x<=136)
15217 {
15218 14 dir=right;
15219 14 }
15220
15221
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 17 times.
381 if(x>=200)
15222 {
15223 17 dir=left;
15224 17 }
15225 }
15226 723 }
15227
15228
4/4
✓ Branch 0 taken 44208 times.
✓ Branch 1 taken 1047 times.
✓ Branch 2 taken 38651 times.
✓ Branch 3 taken 5557 times.
45255 if(clk4>=-1 && !((clk4+1)&7))
15229 {
15230
2/2
✓ Branch 0 taken 2943 times.
✓ Branch 1 taken 2614 times.
5557 if(dir==left)
15231 {
15232 2943 x-=1;
15233 2943 }
15234 else
15235 {
15236 2614 x+=1;
15237 }
15238 5557 }
15239
15240 45255 clk4=(clk4+1)%256;
15241
15242 45255 return enemy::animate(index);
15243 46439 }
15244
15245 46850 void eAquamentus::draw(BITMAP *dest)
15246 {
15247
2/2
✓ Branch 0 taken 26079 times.
✓ Branch 1 taken 20771 times.
46850 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15248 {
15249 26079 xofs=(dmisc1?-16:0);
15250
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26079 times.
✓ Branch 2 taken 10724 times.
✓ Branch 3 taken 15355 times.
26079 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
15251
15252
2/2
✓ Branch 0 taken 662 times.
✓ Branch 1 taken 25417 times.
26079 if(dying)
15253 {
15254 662 xofs=0;
15255 662 enemy::draw(dest);
15256 662 }
15257 else
15258 {
15259 25417 drawblock(dest,15);
15260 }
15261 26079 }
15262 else
15263 {
15264 20771 int32_t xblockofs=((dmisc1)?-16:16);
15265 20771 xofs=0;
15266
15267
4/4
✓ Branch 0 taken 20315 times.
✓ Branch 1 taken 456 times.
✓ Branch 2 taken 522 times.
✓ Branch 3 taken 19793 times.
20771 if(clk<0 || dying)
15268 {
15269 978 enemy::draw(dest);
15270 978 return;
15271 }
15272
1/2
✓ Branch 0 taken 19793 times.
✗ Branch 1 not taken.
19793 if ( do_animation )
15273 {
15274 // face (0=firing, 2=resting)
15275 19793 tile=o_tile+((clk3>0)?0:2);
15276 19793 enemy::draw(dest);
15277 // tail (
15278 19793 tile=o_tile+((clk&16)?1:3);
15279 19793 xofs=xblockofs;
15280 19793 enemy::draw(dest);
15281 // body
15282 19793 yofs+=16;
15283 19793 xofs=0;
15284 19793 tile=o_tile+((clk&16)?20:22);
15285 19793 enemy::draw(dest);
15286 19793 xofs=xblockofs;
15287 19793 tile=o_tile+((clk&16)?21:23);
15288 19793 enemy::draw(dest);
15289 19793 yofs-=16;
15290 19793 }
15291 else enemy::draw(dest);
15292 }
15293 46850 }
15294
15295 9998 bool eAquamentus::hit(weapon *w)
15296 {
15297
3/6
✓ Branch 0 taken 9998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9998 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9998 times.
9998 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk) return false;
15298
15299
2/2
✓ Branch 0 taken 2791 times.
✓ Branch 1 taken 7207 times.
9998 switch(w->id)
15300 {
15301 case wBeam:
15302 case wRefBeam:
15303 case wMagic:
15304 2791 hysz=32;
15305 2791 }
15306
15307
4/4
✓ Branch 0 taken 9873 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 7770 times.
✓ Branch 3 taken 2103 times.
9998 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
15308 9998 hysz=16;
15309 9998 return ret;
15310
15311 9998 }
15312
15313 102 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
15314 102 {
15315
15316
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if ( !(editorflags & ENEMY_FLAG5) )
15317 {
15318
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 x = 128;
15319
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 y = 48;
15320 51 }
15321 else { x = X; y = Y; }
15322
15323 51 Clk=Clk;
15324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(flags & guy_fadeflicker)
15325 {
15326 clk=0;
15327 superman = 1;
15328 fading=fade_flicker;
15329 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
15330 }
15331
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 36 times.
51 else if(flags & guy_fadeinstant)
15332 {
15333 36 clk=0;
15334 36 }
15335 51 hxofs=-16;
15336 51 hxsz=48;
15337 51 clk4=0;
15338
3/6
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 51 times.
✓ Branch 4 taken 51 times.
✗ Branch 5 not taken.
51 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
15339
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 dir=zc_oldrand()%3+1;
15340 51 SIZEflags = d->SIZEflags;
15341
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
51 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15342 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15343 // al_trace("Enemy txsz:%i\n", txsz);
15344
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
51 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
15345
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
51 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
15346
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
51 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
15347
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
51 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
15348
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
15349
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
15350 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15351
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
51 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
15352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15353 {
15354 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
15355 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15356 }
15357
15358
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
51 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
15359
15360 //nets+5340;
15361 51 }
15362
15363 45233 bool eGohma::animate(int32_t index)
15364 {
15365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45233 times.
45233 if(switch_hooked) return enemy::animate(index);
15366
2/2
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 44531 times.
45233 if(dying)
15367 702 return Dead(index);
15368
15369
2/2
✓ Branch 0 taken 44524 times.
✓ Branch 1 taken 7 times.
44531 if(fading)
15370 {
15371
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(++clk4 > 60)
15372 {
15373 7 clk4=0;
15374 7 superman=0;
15375 7 fading=0;
15376 7 clk=0;
15377
15378 7 }
15379 else return enemy::animate(index);
15380 7 }
15381
15382
2/2
✓ Branch 0 taken 44326 times.
✓ Branch 1 taken 205 times.
44531 if(clk==0)
15383 {
15384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if (ffcactivated) removearmosffc(ffcactivated-1);
15385 else
15386 {
15387
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 removearmos(zc_max(x-16, zfix(0)),y);
15388 205 did_armos = false;
15389 205 removearmos(x,y);
15390 205 did_armos = false;
15391
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 removearmos(zc_min(x+16, zfix(255)),y);
15392 }
15393 205 }
15394
15395
2/2
✓ Branch 0 taken 44303 times.
✓ Branch 1 taken 228 times.
44531 if(clk<0) return enemy::animate(index);
15396
15397 // Movement clk must be separate from animation clk because of the Clock item
15398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44303 times.
44303 if(!watch)
15399 44303 clk4++;
15400
15401
2/2
✓ Branch 0 taken 43636 times.
✓ Branch 1 taken 667 times.
44303 if((clk4&63)==0)
15402 {
15403
2/2
✓ Branch 0 taken 348 times.
✓ Branch 1 taken 319 times.
667 if(clk4&64)
15404 348 dir^=1;
15405 else
15406 319 dir=zc_oldrand()%3+1;
15407 667 }
15408
15409
2/2
✓ Branch 0 taken 43589 times.
✓ Branch 1 taken 714 times.
44303 if((clk&63)==3)
15410 {
15411
2/2
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 187 times.
714 switch(dmisc1)
15412 {
15413 case 1:
15414 187 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
15415 187 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
15416 187 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
15417 187 sfx(wpnsfx(wpn),pan(int32_t(x)));
15418 187 break;
15419
15420 default:
15421
3/4
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 442 times.
527 if(dmisc1 != 1 && dmisc1 != 2)
15422 {
15423 442 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
15424 442 sfx(wpnsfx(wpn),pan(int32_t(x)));
15425 442 sfx(wpnsfx(wpn),pan(int32_t(x)));
15426 442 }
15427
15428 527 break;
15429 }
15430 714 }
15431
15432
6/6
✓ Branch 0 taken 5356 times.
✓ Branch 1 taken 38947 times.
✓ Branch 2 taken 5084 times.
✓ Branch 3 taken 272 times.
✓ Branch 4 taken 3692 times.
✓ Branch 5 taken 1392 times.
44303 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
15433 {
15434
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 1209 times.
1392 if(!(clk3%8))
15435 {
15436 183 FireBreath(true);
15437 183 }
15438 1392 }
15439
15440
2/2
✓ Branch 0 taken 22135 times.
✓ Branch 1 taken 22168 times.
44303 if(clk4&1)
15441 22168 move((zfix)1);
15442
15443
2/2
✓ Branch 0 taken 44205 times.
✓ Branch 1 taken 98 times.
44303 if(++clk3>=400)
15444 98 clk3=0;
15445
15446 44303 return enemy::animate(index);
15447 45233 }
15448
15449 45231 void eGohma::draw(BITMAP *dest)
15450 {
15451 45231 tile=o_tile;
15452
15453
4/4
✓ Branch 0 taken 45003 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 702 times.
✓ Branch 3 taken 44301 times.
45231 if(clk<0 || dying)
15454 {
15455 930 enemy::drawzcboss(dest);
15456 930 return;
15457 }
15458
15459
2/2
✓ Branch 0 taken 33103 times.
✓ Branch 1 taken 11198 times.
44301 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15460 {
15461 ///if ( do_animation )
15462 //Yuck. Gohma can just not have this capability right now.
15463 // left side
15464 33103 xofs=-16;
15465 33103 flip=0;
15466 // if(clk&16) tile=180;
15467 // else { tile=182; flip=1; }
15468 33103 tile+=(3*((clk&48)>>4));
15469 33103 enemy::drawzcboss(dest);
15470
15471 // right side
15472 33103 xofs=16;
15473 // tile=(180+182)-tile;
15474 33103 tile=o_tile;
15475 33103 tile+=(3*((clk&48)>>4))+2;
15476 33103 enemy::drawzcboss(dest);
15477
15478 // body
15479 33103 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
15480 33103 tile=o_tile;
15481
15482 // tile+=(3*((clk&24)>>3))+2;
15483
2/2
✓ Branch 0 taken 1743 times.
✓ Branch 1 taken 31360 times.
33103 if(clk3<16)
15484 1743 tile+=7;
15485
2/2
✓ Branch 0 taken 9362 times.
✓ Branch 1 taken 21998 times.
31360 else if(clk3<116)
15486 9362 tile+=10;
15487
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 20683 times.
21998 else if(clk3<132)
15488 1315 tile+=7;
15489 else
15490 20683 tile+=((clk3-132)&24)?4:1;
15491
15492 33103 enemy::drawzcboss(dest);
15493
15494 33103 }
15495 else
15496 {
15497 // left side
15498 11198 xofs=-16;
15499 11198 flip=0;
15500
15501
2/2
✓ Branch 0 taken 5547 times.
✓ Branch 1 taken 5651 times.
11198 if(!(clk&16))
15502 {
15503 5651 tile+=2;
15504 5651 flip=1;
15505 5651 }
15506
15507 11198 enemy::draw(dest);
15508
15509 // right side
15510 11198 tile=o_tile;
15511 11198 xofs=16;
15512
15513
2/2
✓ Branch 0 taken 5651 times.
✓ Branch 1 taken 5547 times.
11198 if((clk&16)) tile+=2;
15514
15515 // tile=(180+182)-tile;
15516 11198 enemy::draw(dest);
15517
15518 // body
15519 11198 tile=o_tile;
15520 11198 xofs=0;
15521
15522
2/2
✓ Branch 0 taken 640 times.
✓ Branch 1 taken 10558 times.
11198 if(clk3<16)
15523 640 tile+=4;
15524
2/2
✓ Branch 0 taken 3418 times.
✓ Branch 1 taken 7140 times.
10558 else if(clk3<116)
15525 3418 tile+=5;
15526
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 6715 times.
7140 else if(clk3<132)
15527 425 tile+=4;
15528 6715 else tile+=((clk3-132)&8)?3:1;
15529
15530 11198 enemy::draw(dest);
15531
15532 }
15533 45231 }
15534
15535 223 int32_t eGohma::takehit(weapon *w, weapon* realweap)
15536 {
15537 223 int32_t wpnId = w->id;
15538 223 int32_t power = w->power;
15539 223 int32_t wpnx = w->x;
15540 223 int32_t wpnDir = w->dir;
15541 223 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
15542
15543
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 105 times.
223 if(def < 0)
15544 {
15545
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 79 times.
✓ Branch 5 taken 26 times.
✓ Branch 6 taken 78 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 65 times.
✓ Branch 9 taken 13 times.
105 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
15546 {
15547 40 sfx(WAV_CHINK,pan(int32_t(x)));
15548 40 return 1;
15549 }
15550 65 }
15551
15552 183 return enemy::takehit(w, realweap);
15553 223 }
15554
15555 388 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15556 388 {
15557 194 count_enemy=(id==(id&0xFFF));
15558 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
15559 194 SIZEflags = d->SIZEflags;
15560
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 194 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
194 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15561 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15562 // al_trace("Enemy txsz:%i\n", txsz);
15563
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 194 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
194 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15564
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 194 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
194 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
15565
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 194 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
194 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
15566
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 194 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
194 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15567
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15568
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15569 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15570
1/4
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
194 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 194 times.
194 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15572 {
15573 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
15574 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15575 }
15576
15577
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 194 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
194 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15578 194 }
15579
15580 73555 bool eLilDig::animate(int32_t index)
15581 {
15582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73555 times.
73555 if(switch_hooked) return enemy::animate(index);
15583
2/2
✓ Branch 0 taken 2952 times.
✓ Branch 1 taken 70603 times.
73555 if(dying)
15584 2952 return Dead(index);
15585
15586
2/2
✓ Branch 0 taken 3995 times.
✓ Branch 1 taken 66608 times.
70603 if(clk==0)
15587 {
15588 3995 removearmos(x,y,ffcactivated);
15589 3995 }
15590
15591
2/2
✓ Branch 0 taken 47497 times.
✓ Branch 1 taken 23106 times.
70603 if(misc<=128)
15592 {
15593
2/2
✓ Branch 0 taken 695 times.
✓ Branch 1 taken 22411 times.
23106 if(!(++misc&31))
15594 695 step+=0.25;
15595 23106 }
15596
15597 70603 variable_walk_8(rate,homing,hrate,spw_floater);
15598 70603 return enemy::animate(index);
15599 73555 }
15600
15601 73406 void eLilDig::draw(BITMAP *dest)
15602 {
15603 73406 tile = o_tile;
15604 // tile = 160;
15605 73406 int32_t fdiv = frate/4;
15606
1/2
✓ Branch 0 taken 73406 times.
✗ Branch 1 not taken.
73406 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15607
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 27095 times.
73406 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
15608 73406 efrate:((clk>=(frate>>1))?1:0);
15609
15610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73406 times.
73406 if ( do_animation )
15611 {
15612
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 27095 times.
73406 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15613 {
15614
9/9
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 5465 times.
✓ Branch 2 taken 5245 times.
✓ Branch 3 taken 5717 times.
✓ Branch 4 taken 5242 times.
✓ Branch 5 taken 4505 times.
✓ Branch 6 taken 3937 times.
✓ Branch 7 taken 5035 times.
✓ Branch 8 taken 5312 times.
46311 switch(dir-8) //directions get screwed up after 8. *shrug*
15615 {
15616 case up: //u
15617 5853 flip=0;
15618 5853 break;
15619
15620 case l_up: //d
15621 5465 flip=0;
15622 5465 tile+=4;
15623 5465 break;
15624
15625 case l_down: //l
15626 5245 flip=0;
15627 5245 tile+=8;
15628 5245 break;
15629
15630 case left: //r
15631 5717 flip=0;
15632 5717 tile+=12;
15633 5717 break;
15634
15635 case r_down: //ul
15636 5242 flip=0;
15637 5242 tile+=20;
15638 5242 break;
15639
15640 case down: //ur
15641 4505 flip=0;
15642 4505 tile+=24;
15643 4505 break;
15644
15645 case r_up: //dl
15646 3937 flip=0;
15647 3937 tile+=28;
15648 3937 break;
15649
15650 case right: //dr
15651 5035 flip=0;
15652 5035 tile+=32;
15653 5035 break;
15654 }
15655
15656 46311 tile+=f2;
15657 46311 }
15658 else
15659 {
15660 27095 tile+=(clk>=6)?1:0;
15661 }
15662 73406 }
15663
15664 73406 enemy::draw(dest);
15665 73406 }
15666
15667 98 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15668 98 {
15669 49 superman=1;
15670
15671 49 SIZEflags = d->SIZEflags;
15672
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
49 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15673 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15674 // al_trace("Enemy txsz:%i\n", txsz);
15675
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
49 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15676
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
15677 49 else hxsz=32;
15678
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
15679 49 else hysz=32;
15680
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15681 49 else hzsz=16; // hard to jump.
15682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15683 49 else hxofs=-8;
15684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15685 49 else hyofs=-8;
15686 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15687
1/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15689 {
15690 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
15691 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15692 }
15693
15694
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15695
15696
15697 49 }
15698
15699 21765 bool eBigDig::animate(int32_t index)
15700 {
15701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21765 times.
21765 if(switch_hooked) return enemy::animate(index);
15702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21765 times.
21765 if(dying)
15703 return Dead(index);
15704
15705
2/2
✓ Branch 0 taken 18680 times.
✓ Branch 1 taken 3085 times.
21765 if(clk==0)
15706 {
15707 3085 removearmos(x,y,ffcactivated);
15708 3085 }
15709
15710
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21681 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 42 times.
21765 switch(misc)
15711 {
15712 case 0:
15713 21681 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
15714 21681 break;
15715
15716 case 1:
15717 42 ++misc;
15718 42 break;
15719
15720 case 2:
15721
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 42 times.
146 for(int32_t i=0; i<dmisc5; i++)
15722 {
15723 104 addenemy(x,y,dmisc1+0x1000,-15);
15724 104 }
15725
15726
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 42 times.
57 for(int32_t i=0; i<dmisc6; i++)
15727 {
15728 15 addenemy(x,y,dmisc2+0x1000,-15);
15729 15 }
15730
15731
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 42 times.
57 for(int32_t i=0; i<dmisc7; i++)
15732 {
15733 15 addenemy(x,y,dmisc3+0x1000,-15);
15734 15 }
15735
15736
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 42 times.
57 for(int32_t i=0; i<dmisc8; i++)
15737 {
15738 15 addenemy(x,y,dmisc4+0x1000,-15);
15739 15 }
15740
15741
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(itemguy) // Hand down the carried item
15742 {
15743 guycarryingitem = guys.Count()-1;
15744 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
15745 itemguy = false;
15746 }
15747
15748 42 stop_bgsfx(index);
15749
15750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
15751
15752 42 return true;
15753 }
15754
15755 21723 return enemy::animate(index);
15756 21765 }
15757
15758 21760 void eBigDig::draw(BITMAP *dest)
15759 {
15760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21760 times.
21760 if(anim!=aDIG)
15761 {
15762 update_enemy_frame();
15763 xofs-=8;
15764 yofs-=8;
15765 drawblock(dest,15);
15766 xofs+=8;
15767 yofs+=8;
15768 return;
15769 }
15770
15771 21760 tile = o_tile;
15772 21760 int32_t fdiv = frate/4;
15773
1/2
✓ Branch 0 taken 21760 times.
✗ Branch 1 not taken.
21760 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15774
15775
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 11522 times.
21760 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
15776 21760 efrate:((clk>=(frate>>1))?1:0);
15777
15778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21760 times.
21760 if ( do_animation )
15779 {
15780
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 11522 times.
21760 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15781 {
15782
9/9
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 1221 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 1195 times.
✓ Branch 4 taken 1233 times.
✓ Branch 5 taken 1223 times.
✓ Branch 6 taken 993 times.
✓ Branch 7 taken 1450 times.
✓ Branch 8 taken 464 times.
10238 switch(dir-8) //directions get screwed up after 8. *shrug*
15783 {
15784 case up: //u
15785 1115 flip=0;
15786 1115 break;
15787
15788 case l_up: //d
15789 1221 flip=0;
15790 1221 tile+=8;
15791 1221 break;
15792
15793 case l_down: //l
15794 1344 flip=0;
15795 1344 tile+=40;
15796 1344 break;
15797
15798 case left: //r
15799 1195 flip=0;
15800 1195 tile+=48;
15801 1195 break;
15802
15803 case r_down: //ul
15804 1233 flip=0;
15805 1233 tile+=80;
15806 1233 break;
15807
15808 case down: //ur
15809 1223 flip=0;
15810 1223 tile+=88;
15811
15812 1223 break;
15813
15814 case r_up: //dl
15815 993 flip=0;
15816 993 tile+=120;
15817 993 break;
15818
15819 case right: //dr
15820 1450 flip=0;
15821 1450 tile+=128;
15822 1450 break;
15823 }
15824
15825 10238 tile+=(f2*2);
15826 10238 }
15827 else
15828 {
15829 11522 tile+=(f2)?0:2;
15830 11522 flip=(clk&1)?1:0;
15831 }
15832 21760 }
15833
15834 21760 xofs-=8;
15835 21760 yofs-=8;
15836 21760 drawblock(dest,15);
15837 21760 xofs+=8;
15838 21760 yofs+=8;
15839 21760 }
15840
15841 738 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
15842 {
15843 738 int32_t wpnId = w->id;
15844
15845
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 696 times.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
738 if(wpnId==wWhistle && misc==0)
15846 42 misc=1;
15847
15848 738 return 0;
15849 }
15850
15851 /*
15852 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15853 {
15854 hxofs=hyofs=8;
15855 hzsz=16; //can't be jumped.
15856 clk2=70;
15857 misc=-1;
15858 mainguy=!getmapflag();
15859 }
15860
15861 bool eGanon::animate(int32_t index)
15862 {
15863 if(switch_hooked) return enemy::animate(index);
15864 if(dying)
15865
15866 return Dead(index);
15867
15868 if(clk==0)
15869 {
15870 removearmos(x,y,ffcactivated);
15871 }
15872
15873 switch(misc)
15874 {
15875 case -1:
15876 misc=0;
15877
15878 case 0:
15879 if(++clk2>72 && !(zc_oldrand()&3))
15880 {
15881 addEwpn(x,y,z,wpn,3,wdp,dir,getUID());
15882 sfx(wpnsfx(wpn),pan(int32_t(x)));
15883 clk2=0;
15884 }
15885
15886 Stunclk=0;
15887 constant_walk(rate,homing,spw_none);
15888 break;
15889
15890 case 1:
15891 case 2:
15892 if(--Stunclk<=0)
15893 {
15894 int32_t r=zc_oldrand();
15895
15896 if(r&1)
15897 {
15898 y=96;
15899
15900 if(r&2)
15901 x=160;
15902 else
15903 x=48;
15904
15905 if(tooclose(x,y,48))
15906 x=208-x;
15907 }
15908
15909 //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2
15910 //{
15911 // loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
15912 // }
15913 // else
15914 // {
15915 loadpalset(csBOSS,pSprite(d->bosspal));
15916 // }
15917 misc=0;
15918 }
15919
15920 break;
15921
15922 case 3:
15923 {
15924 if(hclk>0)
15925 break;
15926
15927 misc=4;
15928 clk=0;
15929 hxofs=1000;
15930 loadpalset(9,pSprite(spPILE));
15931 music_stop();
15932 stop_sfx(WAV_ROAR);
15933
15934 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
15935
15936 sfx(WAV_GANON);
15937 //Ganon's dustpile; fall in sideview. -Z
15938 item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
15939 dustpile->linked_parent = eeGANON;
15940 setmapflag();
15941 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
15942 break;
15943 }
15944
15945 case 4:
15946 if(clk>=80)
15947 {
15948 misc=5;
15949
15950 if(getmapflag())
15951 {
15952 game->lvlitems[dlevel]|=liBOSS;
15953 //play_DmapMusic();
15954 playLevelMusic();
15955 return true;
15956 }
15957
15958 sfx(WAV_CLEARED);
15959 items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0));
15960 setmapflag();
15961 }
15962
15963 break;
15964 }
15965
15966 //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2
15967 //{
15968 //if ( current_item_id(itype_amulet,false) >= 2 )
15969 //{
15970 /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
15971 //}
15972 //}
15973
15974
15975 return enemy::animate(index);
15976 }
15977
15978
15979 int32_t eGanon::takehit(weapon *w, weapon* realweap)
15980 {
15981 //these are here to bypass compiler warnings about unused arguments
15982 int32_t wpnId = w->id;
15983 int32_t power = w->power;
15984 int32_t enemyHitWeapon = w->parentitem;
15985
15986 switch(misc)
15987 {
15988 case 0:
15989 {
15990 //if we're not using the editor defences, and Ganon isn't hit by a sword, return.
15991 if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14))
15992 return 0;
15993
15994 //if we are not using the new defences, just reduce his HP
15995 if (!(editorflags & ENEMY_FLAG14))
15996 {
15997 hp-=power;
15998 if(hp>0)
15999 {
16000 misc=1;
16001 Stunclk=64;
16002 }
16003 else
16004 {
16005 loadpalset(csBOSS,pSprite(spBROWN));
16006 misc=2;
16007 Stunclk=284;
16008 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
16009 }
16010
16011 sfx(WAV_EHIT,pan(int32_t(x)));
16012
16013 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
16014
16015 return 1;
16016 }
16017 //otherwise, resolve his defence.
16018 else
16019 {
16020 int32_t def = enemy::takehit(w,realweap); //This works, but it instantly kills him if it does enough damage.
16021 if(hp>0)
16022 {
16023 misc=1;
16024 Stunclk=64;
16025 }
16026 else
16027 {
16028 loadpalset(csBOSS,pSprite(spBROWN));
16029 misc=2;
16030 Stunclk=284;
16031 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
16032 }
16033
16034 sfx(WAV_EHIT,pan(int32_t(x)));
16035
16036 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
16037
16038
16039 return 1;
16040 }
16041 }
16042 case 2:
16043 {
16044 if
16045 (
16046 ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor
16047 || //or nothing specified, use silver arrows+
16048 ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4))
16049 )
16050 return 0;
16051 {
16052 misc=3;
16053 hclk=81;
16054 loadpalset(9,pSprite(spBROWN));
16055 return 1;
16056 }
16057
16058 }
16059 }
16060
16061 return 0;
16062 }
16063
16064 void eGanon::draw(BITMAP *dest)
16065 {
16066 switch(misc)
16067 {
16068 case 0:
16069 if((clk&3)==3)
16070 tile=(zc_oldrand()%5)*2+o_tile;
16071
16072 if(db!=999)
16073 break;
16074
16075 case 2:
16076 if(Stunclk<64 && (Stunclk&1) )
16077 {
16078 if
16079 (
16080 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
16081 ||
16082 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
16083 )
16084 {
16085 goto ganon_draw; //draw his weapons if we can see him
16086 }
16087 break;
16088 }
16089
16090 case -1:
16091 tile=o_tile;
16092
16093 //fall through
16094 case 1:
16095 case 3:
16096 ganon_draw:
16097 drawblock(dest,15);
16098 break;
16099
16100 case 4:
16101 draw_guts(dest);
16102 draw_flash(dest);
16103 break;
16104 }
16105
16106 if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2
16107 {
16108 if
16109 (
16110 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
16111 ||
16112 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
16113 )
16114 {
16115 draw_guts(dest); //makes his shots visible, but not him
16116 draw_flash(dest);
16117 }
16118 }
16119 }
16120
16121 void eGanon::draw_guts(BITMAP *dest)
16122 {
16123 int32_t c = zc_min(clk>>3,8);
16124 tile = clk<24 ? 74 : 75;
16125 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
16126 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
16127 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
16128 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
16129 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
16130 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
16131 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
16132 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
16133 }
16134
16135 void eGanon::draw_flash(BITMAP *dest)
16136 {
16137
16138 int32_t c = clk-(clk>>2);
16139 cs = (frame&3)+6;
16140 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
16141 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
16142 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
16143 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
16144 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
16145 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
16146 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
16147 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
16148 }
16149 */
16150
16151 14 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
16152 14 {
16153 7 hxofs=hyofs=8;
16154
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if (editorflags & ENEMY_FLAG3)
16155 {
16156 hxofs = 4;
16157 hyofs = 4;
16158 hxsz = 24;
16159 hysz = 24;
16160 SIZEflags|=guyflagOVERRIDE_HIT_WIDTH;
16161 SIZEflags|=guyflagOVERRIDE_HIT_HEIGHT;
16162 }
16163 7 hzsz=16; //can't be jumped.
16164 7 clk2=70;
16165 7 misc=-1;
16166
4/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
7 mainguy=(!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN));
16167 7 }
16168
16169 12107 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
16170 {
16171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12107 times.
12107 if(dying)
16172
16173 return Dead(index);
16174
16175
2/2
✓ Branch 0 taken 12060 times.
✓ Branch 1 taken 47 times.
12107 if(clk==0)
16176 {
16177 47 removearmos(x,y,ffcactivated);
16178 47 }
16179
16180
6/7
✓ Branch 0 taken 2060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8901 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 574 times.
✓ Branch 5 taken 560 times.
✓ Branch 6 taken 5 times.
12107 switch(misc)
16181 {
16182 case -1:
16183 7 misc=0;
16184 [[fallthrough]];
16185 case 0:
16186
4/4
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 8426 times.
✓ Branch 2 taken 361 times.
✓ Branch 3 taken 121 times.
8908 if(++clk2>72 && !(zc_oldrand()&3))
16187 {
16188 121 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16189 121 sfx(wpnsfx(wpn),pan(int32_t(x)));
16190 121 clk2=0;
16191 121 }
16192
16193 8908 Stunclk=0;
16194 8908 constant_walk(rate,homing,spw_none);
16195 8908 break;
16196
16197 case 1:
16198 case 2:
16199
2/2
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 24 times.
2060 if(--Stunclk<=0)
16200 {
16201 24 int32_t r=zc_oldrand();
16202
16203
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 10 times.
24 if(r&1)
16204 {
16205 10 y=96;
16206
16207
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7 times.
10 if(r&2)
16208 3 x=160;
16209 else
16210 7 x=48;
16211
16212
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 if(tooclose(x,y,48))
16213 3 x=208-x;
16214 10 }
16215
16216 24 loadpalset(csBOSS,pSprite(d->bosspal));
16217 24 misc=0;
16218 24 }
16219
16220 2060 break;
16221
16222 case 3:
16223 {
16224
2/2
✓ Branch 0 taken 567 times.
✓ Branch 1 taken 7 times.
574 if(hclk>0)
16225 567 break;
16226
16227 7 misc=4;
16228 7 clk=0;
16229 7 hxofs=1000;
16230 7 loadpalset(9,pSprite(spPILE));
16231 7 music_stop();
16232 7 stop_sfx(WAV_ROAR);
16233
16234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
16235
16236 7 sfx(WAV_GANON);
16237 //Ganon's dustpile; fall in sideview. -Z
16238 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
16239 //dustpile->miscellaneous[31] = eeGANON;
16240
6/12
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
7 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
16241 7 item *dustpile = NULL;
16242 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
16243 7 dustpile = (item *)items.spr(items.Count() - 1);
16244 7 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
16245 //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 )
16246 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
16247 7 break;
16248 }
16249
16250 case 4:
16251
2/2
✓ Branch 0 taken 553 times.
✓ Branch 1 taken 7 times.
560 if(clk>=80)
16252 {
16253 7 misc=5;
16254
16255 //game->lvlitems[dlevel]|=liBOSS;
16256
16257 7 sfx(WAV_CLEARED);
16258 //Add the big TF over the ashes!
16259
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 7 times.
21 for(word q = 0; q < items.Count(); q++)
16260 {
16261 14 item *ashes = (item*)items.spr(q);
16262
3/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 7 times.
14 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
16263 {
16264 //Z_scripterrlog("Found correct dustpile!\n");
16265
4/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
7 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
16266 7 item *bigtriforce = NULL;
16267 7 bigtriforce = (item *)items.spr(items.Count() - 1);
16268 7 bigtriforce->linked_parent = eeGANON;
16269 7 }
16270 14 }
16271 //setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
16272 //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z
16273 7 }
16274
16275 560 break;
16276 5 case 5: return true;
16277 }
16278
16279 12102 return enemy::animate(index);
16280 12107 }
16281
16282
16283 577 int32_t eGanon::takehit(weapon *w, weapon* realweap)
16284 {
16285 //these are here to bypass compiler warnings about unused arguments
16286 577 int32_t wpnId = w->id;
16287 577 int32_t power = w->power;
16288 577 int32_t enemyHitWeapon = w->parentitem;
16289
16290
3/3
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 79 times.
577 switch(misc)
16291 {
16292 case 0:
16293
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 31 times.
54 if(wpnId!=wSword)
16294 23 return 0;
16295
16296 31 hp-=power;
16297
16298
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 7 times.
31 if(hp>0)
16299 {
16300 24 misc=1;
16301 24 Stunclk=64;
16302 24 }
16303 else
16304 {
16305 7 loadpalset(csBOSS,pSprite(spBROWN));
16306 7 misc=2;
16307 7 Stunclk=284;
16308 7 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
16309 }
16310
16311 31 sfx(WAV_EHIT,pan(int32_t(x)));
16312
16313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
16314
16315 31 return 1;
16316
16317 case 2:
16318
4/6
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
79 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
16319 72 return 0;
16320
16321 7 misc=3;
16322 7 hclk=81;
16323 7 loadpalset(9,pSprite(spBROWN));
16324 7 return 1;
16325 }
16326
16327 444 return 0;
16328 577 }
16329
16330 13465 void eGanon::draw(BITMAP *dest)
16331 {
16332
6/6
✓ Branch 0 taken 2110 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 524 times.
✓ Branch 3 taken 1365 times.
✓ Branch 4 taken 8901 times.
✓ Branch 5 taken 560 times.
13465 switch(misc)
16333 {
16334 case 0:
16335
2/2
✓ Branch 0 taken 6676 times.
✓ Branch 1 taken 2225 times.
8901 if((clk&3)==3)
16336 2225 tile=(zc_oldrand()%5)*2+o_tile;
16337
16338
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8901 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8901 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
16339 {
16340
16341 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
16342 {
16343 int odraw = drawstyle;
16344 drawstyle = 2;
16345 drawblock(dest,15);
16346 drawstyle = odraw;
16347 }
16348 else
16349 {
16350 drawblock(dest,15);
16351 }
16352 break;
16353
16354 }
16355
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8901 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8901 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
16356 {
16357 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
16358 {
16359 int odraw = drawstyle;
16360 drawstyle = 2;
16361 drawblock(dest,15);
16362 drawstyle = odraw;
16363 }
16364 else
16365 {
16366 drawblock(dest,15);
16367 }
16368 break;
16369 }
16370
1/2
✓ Branch 0 taken 8901 times.
✗ Branch 1 not taken.
8901 if(db!=999)
16371 8901 break;
16372 [[fallthrough]];
16373 case 2:
16374
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 524 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
524 if(Stunclk<64 && (Stunclk&1))
16375 break;
16376 [[fallthrough]];
16377 case -1:
16378 1889 tile=o_tile;
16379
16380 [[fallthrough]];
16381 case 1:
16382 case 3:
16383 3999 drawblock(dest,15);
16384 3999 break;
16385
16386 case 4:
16387 560 draw_guts(dest);
16388 560 draw_flash(dest);
16389 560 break;
16390 }
16391 13465 }
16392
16393 560 void eGanon::draw_guts(BITMAP *dest)
16394 {
16395
2/2
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 119 times.
560 int32_t c = zc_min(clk>>3,8);
16396 560 tile = clk<24 ? 74 : 75;
16397 560 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
16398 560 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
16399 560 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
16400 560 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
16401 560 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
16402 560 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
16403 560 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
16404 560 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
16405 560 }
16406
16407 560 void eGanon::draw_flash(BITMAP *dest)
16408 {
16409
16410 560 int32_t c = clk-(clk>>2);
16411 560 cs = (frame&3)+6;
16412 560 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
16413 560 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
16414 560 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
16415 560 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
16416 560 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
16417 560 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
16418 560 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
16419 560 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
16420 560 }
16421
16422 7 void getBigTri(int32_t id2)
16423 {
16424 /*
16425 *************************
16426 * BIG TRIFORCE SEQUENCE *
16427 *************************
16428 0 BIGTRI out, WHITE flash in
16429 4 WHITE flash out, PILE cset white
16430 8 WHITE in
16431 ...
16432 188 WHITE out
16433 191 PILE cset red
16434 200 top SHUTTER opens
16435 209 bottom SHUTTER opens
16436 */
16437 7 sfx(itemsbuf[id2].playsound);
16438 7 guys.clear();
16439
16440
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
16441 {
16442 game->lvlitems[dlevel]|=liTRIFORCE;
16443 }
16444
16445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
16446
16447 7 draw_screen(tmpscr);
16448
16449
4/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1344 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 1344 times.
1351 for(int32_t f=0; f<24*8 && !Quit; f++)
16450 {
16451
2/2
✓ Branch 0 taken 1337 times.
✓ Branch 1 taken 7 times.
1344 if(f==4)
16452 {
16453
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 7 times.
112 for(int32_t i=1; i<16; i++)
16454 {
16455 105 RAMpal[CSET(9)+i]=_RGB(63,63,63);
16456 105 }
16457 7 }
16458
16459
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 168 times.
1344 if((f&7)==0)
16460 {
16461
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t cs=2; cs<5; cs++)
16462 {
16463
2/2
✓ Branch 0 taken 7560 times.
✓ Branch 1 taken 504 times.
8064 for(int32_t i=1; i<16; i++)
16464 {
16465 7560 RAMpal[CSET(cs)+i]=_RGB(63,63,63);
16466 7560 }
16467 504 }
16468
16469 168 refreshpal=true;
16470 168 }
16471
16472
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 168 times.
1344 if((f&7)==4)
16473 {
16474
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
16475 else loadlvlpal(0xB);
16476 168 }
16477
16478
2/2
✓ Branch 0 taken 1337 times.
✓ Branch 1 taken 7 times.
1344 if(f==191)
16479 {
16480 7 loadpalset(9,pSprite(spPILE));
16481 7 }
16482
16483 1344 advanceframe(true);
16484 1344 }
16485
16486 //play_DmapMusic();
16487 7 playLevelMusic();
16488
16489
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 if(itemsbuf[id2].flags & ITEM_FLAG1 && currscr < 128)
16490 {
16491 Hero.dowarp(1,0); //side warp
16492 }
16493 7 }
16494
16495 /**********************************/
16496 /*** Multiple-Segment Enemies ***/
16497 /**********************************/
16498
16499
16500 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
16501 170 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
16502 170 {
16503
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if( !(editorflags & ENEMY_FLAG5) )
16504 {
16505
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 x=128;
16506
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 y=48;
16507 85 }
16508 //else { x = X; y = Y; }
16509
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 dir=(zc_oldrand()&7)+8;
16510 85 superman=1;
16511 85 fading=fade_invisible;
16512 85 hxofs=1000;
16513 85 segcnt=clk;
16514 85 segid=Id|0x1000;
16515 85 clk=0;
16516
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 id=guys.Count();
16517
3/6
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 85 times.
✗ Branch 5 not taken.
85 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16518 85 tile=o_tile;
16519 85 hitdir = -1;
16520 85 stickclk = 0;
16521
16522 /*
16523 if (get_bit(quest_rules,qr_NEWENEMYTILES))
16524 {
16525 tile=nets+1220;
16526 }
16527 else
16528 {
16529 tile=57;
16530 }
16531 */
16532 85 }
16533
16534 79409 bool eMoldorm::animate(int32_t index)
16535 {
16536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79409 times.
79409 if(switch_hooked) return enemy::animate(index);
16537 79409 int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z
16538
2/2
✓ Branch 0 taken 61065 times.
✓ Branch 1 taken 18344 times.
79409 if ( y > (max_y) )
16539 {
16540 18344 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
16541 //Z_scripterrlog("Stickclk is %d\n", stickclk);
16542 18344 }
16543
2/2
✓ Branch 0 taken 79034 times.
✓ Branch 1 taken 375 times.
79409 if ( stickclk > 45 )
16544 {
16545 375 stickclk = 0;
16546 375 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
16547 375 }
16548
16549
16550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79409 times.
79409 if(clk==0)
16551 {
16552 79409 removearmos(x,y,ffcactivated);
16553 79409 }
16554
16555
2/2
✓ Branch 0 taken 1083 times.
✓ Branch 1 taken 78326 times.
79409 if(clk2)
16556 {
16557
2/2
✓ Branch 0 taken 1026 times.
✓ Branch 1 taken 57 times.
1083 if(--clk2 == 0)
16558 {
16559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(flags&guy_neverret)
16560 57 never_return(index);
16561
16562
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
57 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
16563 57 leave_item();
16564
16565 57 stop_bgsfx(index);
16566 57 return true;
16567 }
16568 1026 }
16569 else
16570 {
16571
1/2
✓ Branch 0 taken 78326 times.
✗ Branch 1 not taken.
78326 if(stunclk>0)
16572 stunclk=0;
16573 78326 constant_walk_8_old(rate,homing,spw_floater);
16574
16575
16576 78326 misc=dir;
16577
16578 // If any higher-numbered segments were killed, segcnt can be too high,
16579 // leading to a crash
16580
1/2
✓ Branch 0 taken 78326 times.
✗ Branch 1 not taken.
78326 if(index+segcnt>=guys.Count())
16581 segcnt=guys.Count()-index-1;
16582
16583
2/2
✓ Branch 0 taken 78326 times.
✓ Branch 1 taken 429954 times.
508280 for(int32_t i=index+1; i<index+segcnt+1; i++)
16584 {
16585 429954 enemy* segment=((enemy*)guys.spr(i));
16586
16587 // More validation - if segcnt was wrong, this may not
16588 // actually be a Moldorm segment
16589
1/2
✓ Branch 0 taken 429954 times.
✗ Branch 1 not taken.
429954 if(segment->id!=segid)
16590 {
16591 segcnt=i-index-1;
16592 break;
16593 }
16594
16595
2/2
✓ Branch 0 taken 351548 times.
✓ Branch 1 taken 78406 times.
429954 if(i==index+1)
16596 {
16597 78406 x=segment->x;
16598 78406 y=segment->y;
16599 78406 }
16600
16601 429954 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
16602 //Script your own blasted segmented bosses!! -Z
16603 429954 segment->parent_script_UID = this->script_UID;
16604
4/4
✓ Branch 0 taken 78326 times.
✓ Branch 1 taken 351628 times.
✓ Branch 2 taken 11070 times.
✓ Branch 3 taken 67256 times.
429954 if((i==index+segcnt)&&(i!=index+1)) //tail
16605 {
16606 67256 segment->dummy_int[1]=2;
16607 67256 }
16608 else
16609 {
16610 362698 segment->dummy_int[1]=1;
16611 }
16612
16613
2/2
✓ Branch 0 taken 351548 times.
✓ Branch 1 taken 78406 times.
429954 if(i==index+1) //head
16614 {
16615 78406 segment->dummy_int[1]=0;
16616 78406 }
16617
16618
2/2
✓ Branch 0 taken 429599 times.
✓ Branch 1 taken 355 times.
429954 if(segment->hp <= 0)
16619 {
16620 355 int32_t offset=1;
16621
16622
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 577 times.
932 for(int32_t j=i; j<index+segcnt; j++)
16623 {
16624 // Triple-check
16625
1/2
✓ Branch 0 taken 577 times.
✗ Branch 1 not taken.
577 if(((enemy*)guys.spr(j+1))->id!=segid)
16626 {
16627 segcnt=j-index+1; // Add 1 because of --segcnt below
16628 break;
16629 }
16630 577 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
16631 577 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
16632 577 }
16633
16634 355 segment->hclk=33;
16635 355 --segcnt;
16636 355 --i; // Recheck the same index in case multiple segments died at once
16637 355 }
16638 429954 }
16639
16640
2/2
✓ Branch 0 taken 78269 times.
✓ Branch 1 taken 57 times.
78326 if(segcnt==0)
16641 {
16642 57 clk2=19;
16643
16644 57 x=guys.spr(index+1)->x;
16645 57 y=guys.spr(index+1)->y;
16646 57 }
16647 }
16648
16649 79352 return false;
16650 79409 }
16651
16652 970 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
16653 970 {
16654
1/2
✓ Branch 0 taken 485 times.
✗ Branch 1 not taken.
485 if( !(editorflags & ENEMY_FLAG5) )
16655 {
16656
1/2
✓ Branch 0 taken 485 times.
✗ Branch 1 not taken.
485 x=128;
16657
1/2
✓ Branch 0 taken 485 times.
✗ Branch 1 not taken.
485 y=48;
16658 485 }
16659
16660
3/6
✓ Branch 0 taken 485 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 485 times.
✓ Branch 4 taken 485 times.
✗ Branch 5 not taken.
485 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16661 485 hyofs=4;
16662 485 hxsz=hysz=8;
16663 485 hxofs=1000;
16664 485 mainguy=count_enemy=false;
16665 485 parentclk = 0;
16666 485 bgsfx=-1;
16667 485 flags&=~guy_neverret;
16668 //deadsfx = WAV_EDEAD;
16669 485 isCore = false;
16670 485 }
16671
16672 436344 bool esMoldorm::animate(int32_t index)
16673 {
16674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436344 times.
436344 if(switch_hooked) return enemy::animate(index);
16675 // Shouldn't be possible, but better to be sure
16676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436344 times.
436344 if(index==0)
16677 dying=true;
16678
16679
2/2
✓ Branch 0 taken 6390 times.
✓ Branch 1 taken 429954 times.
436344 if(dying)
16680 {
16681
1/2
✓ Branch 0 taken 6390 times.
✗ Branch 1 not taken.
6390 if(!dmisc2)
16682 6390 item_set=0;
16683
16684 6390 return Dead(index);
16685 }
16686
16687
2/2
✓ Branch 0 taken 20598 times.
✓ Branch 1 taken 409356 times.
429954 if(clk>=0)
16688 {
16689 409356 hxofs=4;
16690 409356 step=((enemy*)guys.spr(index-1))->step;
16691
16692
2/2
✓ Branch 0 taken 31229 times.
✓ Branch 1 taken 378127 times.
409356 if(parentclk == 0)
16693 {
16694 31229 misc=dir;
16695 31229 dir=((enemy*)guys.spr(index-1))->misc;
16696 //do alignment, as in parent's animation :-/ -DD
16697 31229 x.doFloor();
16698 31229 y.doFloor();
16699 31229 }
16700
16701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 409356 times.
409356 if(step)
16702 409356 parentclk=(parentclk+1)%((int32_t)(8.0/step));
16703
16704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 409356 times.
409356 if(!watch)
16705 {
16706 409356 sprite::move(step);
16707 409356 }
16708 409356 }
16709
16710 429954 return enemy::animate(index);
16711 436344 }
16712
16713 1645 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
16714 {
16715
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 147 times.
1645 if(enemy::takehit(w,realweap))
16716 1498 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
16717
16718 147 return 0;
16719 1645 }
16720
16721 438294 void esMoldorm::draw(BITMAP *dest)
16722 {
16723 438294 tile=o_tile;
16724 438294 int32_t fdiv = frate/4;
16725
1/2
✓ Branch 0 taken 438294 times.
✗ Branch 1 not taken.
438294 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
16726
16727
2/2
✓ Branch 0 taken 361156 times.
✓ Branch 1 taken 77138 times.
438294 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
16728 438294 efrate:((clk>=(frate>>1))?1:0);
16729
16730
2/2
✓ Branch 0 taken 77138 times.
✓ Branch 1 taken 361156 times.
438294 if(get_bit(quest_rules,qr_NEWENEMYTILES))
16731 {
16732 361156 tile+=dummy_int[1]*40;
16733
16734
2/2
✓ Branch 0 taken 16310 times.
✓ Branch 1 taken 344846 times.
361156 if(dir<8)
16735 {
16736 16310 flip=0;
16737
2/2
✓ Branch 0 taken 12412 times.
✓ Branch 1 taken 3898 times.
16310 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
16738
16739
1/2
✓ Branch 0 taken 16310 times.
✗ Branch 1 not taken.
16310 if(dir>3) // Skip to the next row for diagonals
16740 tile+=4;
16741 16310 }
16742 else
16743 {
16744
8/9
✓ Branch 0 taken 37639 times.
✓ Branch 1 taken 47584 times.
✓ Branch 2 taken 38450 times.
✓ Branch 3 taken 47147 times.
✓ Branch 4 taken 39397 times.
✓ Branch 5 taken 38189 times.
✓ Branch 6 taken 46292 times.
✓ Branch 7 taken 50148 times.
✗ Branch 8 not taken.
344846 switch(dir-8) //directions get screwed up after 8. *shrug*
16745 {
16746 case up: //u
16747 37639 flip=0;
16748 37639 break;
16749
16750 case l_up: //d
16751 47584 flip=0;
16752 47584 tile+=4;
16753 47584 break;
16754
16755 case l_down: //l
16756 38450 flip=0;
16757 38450 tile+=8;
16758 38450 break;
16759
16760 case left: //r
16761 47147 flip=0;
16762 47147 tile+=12;
16763 47147 break;
16764
16765 case r_down: //ul
16766 39397 flip=0;
16767 39397 tile+=20;
16768 39397 break;
16769
16770 case down: //ur
16771 38189 flip=0;
16772 38189 tile+=24;
16773 38189 break;
16774
16775 case r_up: //dl
16776 46292 flip=0;
16777 46292 tile+=28;
16778 46292 break;
16779
16780 case right: //dr
16781 50148 flip=0;
16782 50148 tile+=32;
16783 50148 break;
16784 }
16785 }
16786
16787 361156 tile+=f2;
16788 361156 }
16789
16790
2/2
✓ Branch 0 taken 20652 times.
✓ Branch 1 taken 417642 times.
438294 if(clk>=0)
16791 417642 enemy::draw(dest);
16792 438294 }
16793
16794 222 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
16795 222 {
16796
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if( !(editorflags & ENEMY_FLAG5) )
16797 {
16798
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 x=64;
16799
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 y=80;
16800 111 }
16801 //else { x = X; y = Y; }
16802 //zprint2("lanmola index is %d\n", index);
16803 //byte legaldirs = 0;
16804 111 int32_t incr = 16;
16805 //int32_t possiiblepos = 0;
16806 //int32_t positions[8] = {0};
16807
16808 //Don't spawn in pits.
16809
5/8
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 107 times.
✓ Branch 7 taken 4 times.
111 if ( m_walkflag_simple(x, y) )
16810 {
16811 //zprint2("Can't spawn here.\n");
16812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 for ( ; incr < 240; incr += 16 )
16813 {
16814 //move if we spawn over a pit
16815 //check each direction
16816
6/12
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
4 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
16817 {
16818 //zprint2("Spawn adjustment: -x (%d)\n", incr);
16819
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
16820 }
16821 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
16822 {
16823 //zprint2("Spawn adjustment: +x (%d)\n", incr);
16824 x+=incr; break;
16825 }
16826 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
16827 {
16828 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
16829 x-=incr; y-=incr; break;
16830 }
16831 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
16832 {
16833 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
16834 x+=incr; y-=incr; break;
16835 }
16836 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
16837 {
16838 //zprint2("Spawn adjustment: -y (%d)\n", incr);
16839 y -= incr; break;
16840 }
16841 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
16842 {
16843 //zprint2("Spawn adjustment: +y (%d)\n", incr);
16844 y+=incr; break;
16845 }
16846 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
16847 {
16848 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
16849 x-=incr; y+=incr; break;
16850 }
16851 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
16852 {
16853 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
16854 x+=incr; y+=incr; break;
16855 }
16856 else continue;
16857
16858 }
16859
16860 4 }
16861
16862 111 dir=up;
16863 111 superman=1;
16864 111 fading=fade_invisible;
16865 111 hxofs=1000;
16866 111 segcnt=clk;
16867 111 clk=0;
16868 //set up move history
16869
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 919 times.
1030 for(int32_t i=0; i <= (1<<dmisc2); i++)
16870
3/6
✓ Branch 0 taken 919 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 919 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 919 times.
✗ Branch 5 not taken.
919 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
16871 111 }
16872
16873 101741 bool eLanmola::animate(int32_t index)
16874 {
16875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101741 times.
101741 if(switch_hooked) return enemy::animate(index);
16876
2/2
✓ Branch 0 taken 86454 times.
✓ Branch 1 taken 15287 times.
101741 if(clk==0)
16877 {
16878 15287 removearmos(x,y,ffcactivated);
16879 15287 }
16880
16881
2/2
✓ Branch 0 taken 1786 times.
✓ Branch 1 taken 99955 times.
101741 if(clk2)
16882 {
16883
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 94 times.
1786 if(--clk2 == 0)
16884 {
16885
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 20 times.
94 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
16886 74 leave_item();
16887
16888 94 stop_bgsfx(index);
16889 94 return true;
16890 }
16891
16892 1692 return false;
16893 }
16894
16895
16896 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
16897 //the direction AND x,y position of the lanmola to vary in uncertain ways.
16898 //I've added a complete movement history to this enemy to compensate -DD
16899 99955 constant_walk(rate,homing,spw_none);
16900 99955 prevState.pop_front();
16901 99955 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
16902
16903 // This could cause a crash with Moldorms. I didn't see the same problem
16904 // with Lanmolas, but it looks like it ought to be possible, so here's
16905 // the same solution. - Saf
16906
1/2
✓ Branch 0 taken 99955 times.
✗ Branch 1 not taken.
99955 if(index+segcnt>=guys.Count())
16907 segcnt=guys.Count()-index-1;
16908
16909
2/2
✓ Branch 0 taken 99955 times.
✓ Branch 1 taken 447285 times.
547240 for(int32_t i=index+1; i<index+segcnt+1; i++)
16910 {
16911 447285 enemy* segment=((enemy*)guys.spr(i));
16912
16913 // More validation in case segcnt is wrong
16914
1/2
✓ Branch 0 taken 447285 times.
✗ Branch 1 not taken.
447285 if((segment->id&0xFFF)!=(id&0xFFF))
16915 {
16916 segcnt=i-index-1;
16917 break;
16918 }
16919
16920 447285 segment->o_tile=o_tile;
16921 447285 segment->parent_script_UID = this->script_UID;
16922
4/4
✓ Branch 0 taken 99955 times.
✓ Branch 1 taken 347330 times.
✓ Branch 2 taken 18643 times.
✓ Branch 3 taken 81312 times.
447285 if((i==index+segcnt)&&(i!=index+1))
16923 {
16924 81312 segment->dummy_int[1]=1; //tail
16925 81312 }
16926 else
16927 {
16928 365973 segment->dummy_int[1]=0;
16929 }
16930
16931
2/2
✓ Branch 0 taken 446743 times.
✓ Branch 1 taken 542 times.
447285 if(segment->hp <= 0)
16932 {
16933
2/2
✓ Branch 0 taken 542 times.
✓ Branch 1 taken 937 times.
1479 for(int32_t j=i; j<index+segcnt; j++)
16934 {
16935 // Triple-check
16936
1/2
✓ Branch 0 taken 937 times.
✗ Branch 1 not taken.
937 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
16937 {
16938 segcnt=j-index+1; // Add 1 because of --segcnt below
16939 break;
16940 }
16941 937 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
16942 937 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
16943 937 }
16944
16945 542 ((enemy*)guys.spr(i))->hclk=33;
16946 542 --segcnt;
16947 542 --i; // Recheck the same index in case multiple segments died at once
16948 542 }
16949 447285 }
16950
16951
2/2
✓ Branch 0 taken 99861 times.
✓ Branch 1 taken 94 times.
99955 if(segcnt==0)
16952 {
16953 94 clk2=19;
16954 94 x=guys.spr(index+1)->x;
16955 94 y=guys.spr(index+1)->y;
16956 94 setmapflag(mTMPNORET);
16957 94 }
16958
16959 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
16960 //which is... disastrous.
16961 99955 hp = 1;
16962 99955 return enemy::animate(index);
16963 101741 }
16964
16965 1220 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
16966 1220 {
16967
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if( !(editorflags & ENEMY_FLAG5) )
16968 {
16969
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 x=64;
16970
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 y=80;
16971 610 }
16972 610 int32_t incr = 16;
16973 //Don't spawn in pits.
16974
5/8
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 610 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 590 times.
✓ Branch 7 taken 20 times.
610 if ( m_walkflag_simple(x, y) )
16975 {
16976 //zprint2("Can't spawn here.\n");
16977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for ( ; incr < 240; incr += 16 )
16978 {
16979 //move if we spawn over a pit
16980 //check each direction
16981
6/12
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
20 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
16982 {
16983 //zprint2("Spawn adjustment: -x (%d)\n", incr);
16984
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
16985 }
16986 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
16987 {
16988 //zprint2("Spawn adjustment: +x (%d)\n", incr);
16989 x+=incr; break;
16990 }
16991 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
16992 {
16993 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
16994 x-=incr; y-=incr; break;
16995 }
16996 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
16997 {
16998 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
16999 x+=incr; y-=incr; break;
17000 }
17001 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
17002 {
17003 //zprint2("Spawn adjustment: -y (%d)\n", incr);
17004 y -= incr; break;
17005 }
17006 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
17007 {
17008 //zprint2("Spawn adjustment: +y (%d)\n", incr);
17009 y+=incr; break;
17010 }
17011 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
17012 {
17013 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
17014 x-=incr; y+=incr; break;
17015 }
17016 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
17017 {
17018 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
17019 x+=incr; y+=incr; break;
17020 }
17021 else continue;
17022
17023 }
17024
17025 20 }
17026
17027 610 hxofs=1000;
17028 610 hxsz=8;
17029 610 mainguy=false;
17030 610 count_enemy=(id<0x2000)?true:false;
17031
17032 //set up move history
17033
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 5050 times.
5660 for(int32_t i=0; i <= (1<<dmisc2); i++)
17034
3/6
✓ Branch 0 taken 5050 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5050 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5050 times.
✗ Branch 5 not taken.
5050 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
17035
17036 610 bgsfx = -1;
17037 610 isCore = false;
17038 610 flags&=~guy_neverret;
17039 610 }
17040
17041 457041 bool esLanmola::animate(int32_t index)
17042 {
17043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 457041 times.
457041 if(switch_hooked) return enemy::animate(index);
17044 // Shouldn't be possible, but who knows
17045
1/2
✓ Branch 0 taken 457041 times.
✗ Branch 1 not taken.
457041 if(index==0)
17046 dying=true;
17047
17048
2/2
✓ Branch 0 taken 9756 times.
✓ Branch 1 taken 447285 times.
457041 if(dying)
17049 {
17050 9756 xofs=0;
17051
17052
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 7956 times.
9756 if(!dmisc3)
17053 7956 item_set=0;
17054
17055 9756 return Dead(index);
17056 }
17057
17058
2/2
✓ Branch 0 taken 12880 times.
✓ Branch 1 taken 434405 times.
447285 if(clk>=0)
17059 {
17060 434405 hxofs=4;
17061
17062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434405 times.
434405 if(!watch)
17063 {
17064 434405 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
17065 434405 prevState.pop_front();
17066 434405 prevState.push_back(newstate);
17067 434405 x = newstate.first.first;
17068 434405 y = newstate.first.second;
17069 434405 dir = newstate.second;
17070 434405 }
17071 434405 }
17072
17073 447285 return enemy::animate(index);
17074 457041 }
17075
17076 1460 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
17077 {
17078
2/2
✓ Branch 0 taken 1329 times.
✓ Branch 1 taken 131 times.
1460 if(enemy::takehit(w,realweap))
17079 1329 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
17080
17081 131 return 0;
17082 1460 }
17083
17084 458312 void esLanmola::draw(BITMAP *dest)
17085 {
17086 458312 tile=o_tile;
17087 458312 int32_t fdiv = frate/4;
17088
1/2
✓ Branch 0 taken 458312 times.
✗ Branch 1 not taken.
458312 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
17089
17090
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 120779 times.
458312 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
17091 458312 efrate:((clk>=(frate>>1))?1:0);
17092
17093
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 120779 times.
458312 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17094 {
17095
2/2
✓ Branch 0 taken 68269 times.
✓ Branch 1 taken 269264 times.
337533 if(id>=0x2000)
17096 {
17097 269264 tile+=20;
17098
17099
2/2
✓ Branch 0 taken 209782 times.
✓ Branch 1 taken 59482 times.
269264 if(dummy_int[1]==1)
17100 {
17101 59482 tile+=20;
17102 59482 }
17103 269264 }
17104
17105
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 70158 times.
✓ Branch 2 taken 71956 times.
✓ Branch 3 taken 93557 times.
✓ Branch 4 taken 101862 times.
337533 switch(dir)
17106 {
17107 case up:
17108 70158 flip=0;
17109 70158 break;
17110
17111 case down:
17112 71956 flip=0;
17113 71956 tile+=4;
17114 71956 break;
17115
17116 case left:
17117 93557 flip=0;
17118 93557 tile+=8;
17119 93557 break;
17120
17121 case right:
17122 101862 flip=0;
17123 101862 tile+=12;
17124 101862 break;
17125 }
17126
17127 337533 tile+=f2;
17128 337533 }
17129 else
17130 {
17131
2/2
✓ Branch 0 taken 33890 times.
✓ Branch 1 taken 86889 times.
120779 if(id>=0x2000)
17132 {
17133 86889 tile+=1;
17134 86889 }
17135 }
17136
17137
2/2
✓ Branch 0 taken 12880 times.
✓ Branch 1 taken 445432 times.
458312 if(clk>=0)
17138 445432 enemy::draw(dest);
17139 458312 }
17140
17141 116 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
17142 116 {
17143 //these are here to bypass compiler warnings about unused arguments
17144 58 Clk=Clk;
17145 58 superman=1;
17146
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 dir=(zc_oldrand()&7)+8;
17147 58 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
17148
17149
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 58 times.
322 for(int32_t i=0; i<armcnt; i++)
17150 264 arm[i]=i;
17151
17152 58 fading=fade_blue_poof;
17153 //nets+4680;
17154 58 adjusted=false;
17155 58 SIZEflags = d->SIZEflags; //Probably will be buggy. -Z 12 AUG 2020
17156
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17157 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17158 // al_trace("Enemy txsz:%i\n", txsz);
17159
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
17160
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
17161
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
17162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
17163
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
17164
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
17165 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17166
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
17167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17168 {
17169 yofs = d->yofs+(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17170 }
17171
17172
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
17173 58 }
17174
17175 30211 bool eManhandla::animate(int32_t index)
17176 {
17177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30211 times.
30211 if(switch_hooked) return enemy::animate(index);
17178
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 29455 times.
30211 if(dying)
17179 756 return Dead(index);
17180
17181
2/2
✓ Branch 0 taken 28252 times.
✓ Branch 1 taken 1203 times.
29455 if(clk==0)
17182 {
17183 1203 removearmos(x,y,ffcactivated);
17184 1203 }
17185
17186
17187 // check arm status, move dead ones to end of group
17188
2/2
✓ Branch 0 taken 92084 times.
✓ Branch 1 taken 29455 times.
121539 for(int32_t i=0; i<armcnt; i++)
17189 {
17190 92084 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
17191
3/4
✓ Branch 0 taken 92084 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 91884 times.
92084 if(!cur_arm || cur_arm->dying)
17192 {
17193
2/2
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 200 times.
446 for(int32_t j=i; j<armcnt-1; j++)
17194 {
17195 246 zc_swap(arm[j],arm[j+1]);
17196 246 guys.swap(index+j+1,index+j+2);
17197 246 }
17198
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 32 times.
200 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
17199 {
17200 32 leave_item();
17201 32 }
17202 200 --armcnt;
17203 200 --i;
17204 200 continue;
17205 }
17206
2/2
✓ Branch 0 taken 91620 times.
✓ Branch 1 taken 264 times.
91884 if(!adjusted)
17207 {
17208
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 64 times.
264 if(!dmisc2)
17209 {
17210 200 cur_arm->o_tile=o_tile+40;
17211 200 cur_arm->parent_script_UID = this->script_UID;
17212 200 }
17213 else
17214 {
17215 64 cur_arm->o_tile=o_tile+160;
17216 64 cur_arm->parent_script_UID = this->script_UID;
17217 }
17218 264 }
17219 91884 }
17220
17221 29455 adjusted=true;
17222
17223 // move or die
17224
2/2
✓ Branch 0 taken 29413 times.
✓ Branch 1 taken 42 times.
29455 if(armcnt==0)
17225 42 hp=0;
17226 else
17227 {
17228 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
17229
1/2
✓ Branch 0 taken 29413 times.
✗ Branch 1 not taken.
29413 step=zc_min(zfix(4.5),(((!dmisc2)?4:8)-int64_t(armcnt))*0.5+zslongToFix(dstep*100));
17230 29413 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
17231
17232
2/2
✓ Branch 0 taken 26532 times.
✓ Branch 1 taken 2881 times.
29413 if(!dmisc2)
17233 {
17234
2/2
✓ Branch 0 taken 77897 times.
✓ Branch 1 taken 26532 times.
104429 for(int32_t i=0; i<armcnt; i++)
17235 {
17236
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18618 times.
✓ Branch 2 taken 20692 times.
✓ Branch 3 taken 19238 times.
✓ Branch 4 taken 19349 times.
77897 switch(arm[i])
17237 {
17238 case 0:
17239 18618 dy1=-24;
17240 18618 break;
17241
17242 case 1:
17243 20692 dy2=31;
17244 20692 break;
17245
17246 case 2:
17247 19238 dx1=-16;
17248 19238 break;
17249
17250 case 3:
17251 19349 dx2=31;
17252 19349 break;
17253 }
17254 77897 }
17255 26532 }
17256 else
17257 {
17258 2881 dx1=-8, dy1=-16, dx2=23, dy2=23;
17259
17260
2/2
✓ Branch 0 taken 13987 times.
✓ Branch 1 taken 2881 times.
16868 for(int32_t i=0; i<armcnt; i++)
17261 {
17262
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4279 times.
✓ Branch 2 taken 3184 times.
✓ Branch 3 taken 2549 times.
✓ Branch 4 taken 3975 times.
13987 switch(arm[i]&3)
17263 {
17264 case 0:
17265 4279 dy1=-32;
17266 4279 break;
17267
17268 case 1:
17269 3184 dy2=39;
17270 3184 break;
17271
17272 case 2:
17273 2549 dx1=-24;
17274 2549 break;
17275
17276 case 3:
17277 3975 dx2=39;
17278 3975 break;
17279 }
17280 13987 }
17281 }
17282
17283 29413 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
17284
17285
2/2
✓ Branch 0 taken 91884 times.
✓ Branch 1 taken 29413 times.
121297 for(int32_t i=0; i<armcnt; i++)
17286 {
17287 91884 zfix dx=(zfix)0,dy=(zfix)0;
17288
17289
2/2
✓ Branch 0 taken 77897 times.
✓ Branch 1 taken 13987 times.
91884 if(!dmisc2)
17290 {
17291
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18618 times.
✓ Branch 2 taken 20692 times.
✓ Branch 3 taken 19238 times.
✓ Branch 4 taken 19349 times.
77897 switch(arm[i])
17292 {
17293 case 0:
17294 18618 dy=-16;
17295 18618 break;
17296
17297 case 1:
17298 20692 dy=16;
17299 20692 break;
17300
17301 case 2:
17302 19238 dx=-16;
17303 19238 break;
17304
17305 case 3:
17306 19349 dx=16;
17307 19349 break;
17308 }
17309 77897 }
17310 else
17311 {
17312
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
✓ Branch 2 taken 1789 times.
✓ Branch 3 taken 1292 times.
✓ Branch 4 taken 2015 times.
✓ Branch 5 taken 2599 times.
✓ Branch 6 taken 1395 times.
✓ Branch 7 taken 1257 times.
✓ Branch 8 taken 1960 times.
13987 switch(arm[i])
17313 {
17314 case 0:
17315 1680 dy=-24;
17316 1680 dx=-8;
17317 1680 break;
17318
17319 case 1:
17320 1789 dy=24;
17321 1789 dx=8;
17322 1789 break;
17323
17324 case 2:
17325 1292 dx=-24;
17326 1292 dy=8;
17327 1292 break;
17328
17329 case 3:
17330 2015 dx=24;
17331 2015 dy=-8;
17332 2015 break;
17333
17334 case 4:
17335 2599 dy=-24;
17336 2599 dx=8;
17337 2599 break;
17338
17339 case 5:
17340 1395 dy=24;
17341 1395 dx=-8;
17342 1395 break;
17343
17344 case 6:
17345 1257 dx=-24;
17346 1257 dy=-8;
17347 1257 break;
17348
17349 case 7:
17350 1960 dx=24;
17351 1960 dy=8;
17352 1960 break;
17353 }
17354 }
17355
17356 91884 guys.spr(index+i+1)->x = x+dx;
17357 91884 guys.spr(index+i+1)->y = y+dy;
17358 91884 }
17359 }
17360
17361 29455 return enemy::animate(index);
17362 30211 }
17363
17364
17365 1300 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
17366 {
17367 1300 int32_t wpnId = w->id;
17368
17369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1300 times.
1300 if(dying)
17370 return 0;
17371
17372
3/4
✓ Branch 0 taken 850 times.
✓ Branch 1 taken 433 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
1300 switch(wpnId)
17373 {
17374 case wBomb:
17375 case wSBomb:
17376 case wSword:
17377 case wHammer:
17378 case wWand:
17379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if (get_bit(quest_rules, qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
17380
17381 case wLitBomb:
17382 case wLitSBomb:
17383 case wBait:
17384 case wWhistle:
17385 case wFire:
17386 case wWind:
17387 case wSSparkle:
17388 case wFSparkle:
17389 case wPhantom:
17390 1283 return 0;
17391
17392 case wHookshot:
17393 case wBrang:
17394 sfx(WAV_CHINK,pan(int32_t(x)));
17395 break;
17396
17397 default:
17398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if (get_bit(quest_rules, qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
17399 else sfx(WAV_CHINK,pan(int32_t(x)));
17400
17401 17 }
17402
17403 17 return 1;
17404 1300 }
17405
17406 30209 void eManhandla::draw(BITMAP *dest)
17407 {
17408 30209 tile=o_tile;
17409 30209 int32_t fdiv = frate/4;
17410
1/2
✓ Branch 0 taken 30209 times.
✗ Branch 1 not taken.
30209 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
17411
17412
2/2
✓ Branch 0 taken 21250 times.
✓ Branch 1 taken 8959 times.
30209 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
17413 30209 efrate:((clk>=(frate>>1))?1:0);
17414
17415
2/2
✓ Branch 0 taken 21250 times.
✓ Branch 1 taken 8959 times.
30209 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17416 {
17417
2/2
✓ Branch 0 taken 2518 times.
✓ Branch 1 taken 18732 times.
21250 if(!dmisc2)
17418 {
17419
8/9
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 2084 times.
✓ Branch 2 taken 2751 times.
✓ Branch 3 taken 2878 times.
✓ Branch 4 taken 1783 times.
✓ Branch 5 taken 1846 times.
✓ Branch 6 taken 1929 times.
✓ Branch 7 taken 3061 times.
✗ Branch 8 not taken.
18732 switch(dir-8) //directions get screwed up after 8. *shrug*
17420 {
17421 case up: //u
17422 2400 flip=0;
17423 2400 break;
17424
17425 case l_up: //d
17426 2084 flip=0;
17427 2084 tile+=4;
17428 2084 break;
17429
17430 case l_down: //l
17431 2751 flip=0;
17432 2751 tile+=8;
17433 2751 break;
17434
17435 case left: //r
17436 2878 flip=0;
17437 2878 tile+=12;
17438 2878 break;
17439
17440 case r_down: //ul
17441 1783 flip=0;
17442 1783 tile+=20;
17443 1783 break;
17444
17445 case down: //ur
17446 1846 flip=0;
17447 1846 tile+=24;
17448 1846 break;
17449
17450 case r_up: //dl
17451 1929 flip=0;
17452 1929 tile+=28;
17453 1929 break;
17454
17455 case right: //dr
17456 3061 flip=0;
17457 3061 tile+=32;
17458 3061 break;
17459 }
17460
17461 18732 tile+=f2;
17462 18732 enemy::draw(dest);
17463 18732 } //manhandla 2, big body
17464 else
17465 {
17466
17467
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 357 times.
✓ Branch 2 taken 483 times.
✓ Branch 3 taken 500 times.
✓ Branch 4 taken 315 times.
✓ Branch 5 taken 196 times.
✓ Branch 6 taken 215 times.
✓ Branch 7 taken 164 times.
✓ Branch 8 taken 288 times.
2518 switch(dir-8) //directions get screwed up after 8. *shrug*
17468 {
17469 case up: //u
17470 357 flip=0;
17471 357 break;
17472
17473 case l_up: //d
17474 483 flip=0;
17475 483 tile+=8;
17476 483 break;
17477
17478 case l_down: //l
17479 500 flip=0;
17480 500 tile+=40;
17481 500 break;
17482
17483 case left: //r
17484 315 flip=0;
17485 315 tile+=48;
17486 315 break;
17487
17488 case r_down: //ul
17489 196 flip=0;
17490 196 tile+=80;
17491 196 break;
17492
17493 case down: //ur
17494 215 flip=0;
17495 215 tile+=88;
17496 215 break;
17497
17498 case r_up: //dl
17499 164 flip=0;
17500 164 tile+=120;
17501 164 break;
17502
17503 case right: //dr
17504 288 flip=0;
17505 288 tile+=128;
17506 288 break;
17507 }
17508
17509 2518 tile+=(f2*2);
17510 2518 xofs-=8;
17511 2518 yofs-=8;
17512 2518 drawblock(dest,15);
17513 2518 xofs+=8;
17514 2518 yofs+=8;
17515 }
17516 21250 }
17517 else
17518 {
17519
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 8444 times.
8959 if(!dmisc2)
17520 {
17521 8444 enemy::draw(dest);
17522 8444 }
17523 else
17524 {
17525 515 xofs-=8;
17526 515 yofs-=8;
17527 515 enemy::draw(dest);
17528 515 xofs+=16;
17529 515 enemy::draw(dest);
17530 515 yofs+=16;
17531 515 enemy::draw(dest);
17532 515 xofs-=16;
17533 515 enemy::draw(dest);
17534 515 xofs+=8;
17535 515 yofs-=8;
17536 }
17537 }
17538 30209 }
17539
17540 528 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
17541 528 {
17542 264 id=misc=clk;
17543 264 dir = clk & 3;
17544 264 clk=0;
17545 264 mainguy=count_enemy=false;
17546 264 dummy_bool[0]=false;
17547 264 item_set=0;
17548 264 bgsfx=-1;
17549 264 deadsfx = WAV_EDEAD;
17550 264 flags &= (~guy_neverret);
17551 264 isCore = false;
17552 //Probably will be buggy. -Z 12 AUG 2020
17553 264 SIZEflags = d->SIZEflags;
17554
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
264 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17555 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17556 // al_trace("Enemy txsz:%i\n", txsz);
17557
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
264 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
17558
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
264 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
17559
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
264 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
17560
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
264 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
17561
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
17562
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
17563 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17564
1/4
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
264 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
17565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17566 {
17567 yofs = d->yofs+(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17568 }
17569
17570
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
264 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
17571 264 }
17572
17573 95484 bool esManhandla::animate(int32_t index)
17574 {
17575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95484 times.
95484 if(switch_hooked) return enemy::animate(index);
17576
2/2
✓ Branch 0 taken 3600 times.
✓ Branch 1 taken 91884 times.
95484 if(dying)
17577 3600 return Dead(index);
17578
17579
2/2
✓ Branch 0 taken 5865 times.
✓ Branch 1 taken 86019 times.
91884 if(clk==0)
17580 {
17581 5865 removearmos(x,y,ffcactivated);
17582 5865 }
17583
17584
2/2
✓ Branch 0 taken 78632 times.
✓ Branch 1 taken 13252 times.
91884 if(--clk2<=0)
17585 {
17586 13252 clk2=unsigned(zc_oldrand())%5+5;
17587 13252 clk3^=1;
17588 13252 }
17589
17590
2/2
✓ Branch 0 taken 725 times.
✓ Branch 1 taken 91159 times.
91884 if(!(zc_oldrand()&127))
17591 {
17592 725 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
17593 725 sfx(wpnsfx(wpn),pan(int32_t(x)));
17594 725 }
17595
17596 91884 return enemy::animate(index);
17597 95484 }
17598
17599 95476 void esManhandla::draw(BITMAP *dest)
17600 {
17601 95476 tile=o_tile;
17602 95476 int32_t fdiv = frate/4;
17603
1/2
✓ Branch 0 taken 95476 times.
✗ Branch 1 not taken.
95476 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
17604
2/2
✓ Branch 0 taken 70295 times.
✓ Branch 1 taken 25181 times.
95476 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
17605 95476 efrate:((clk>=(frate>>1))?1:0);
17606
17607
2/2
✓ Branch 0 taken 70295 times.
✓ Branch 1 taken 25181 times.
95476 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17608 {
17609
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 16874 times.
✓ Branch 2 taken 18626 times.
✓ Branch 3 taken 17275 times.
✓ Branch 4 taken 17520 times.
70295 switch(misc&3)
17610 {
17611 case up:
17612 16874 break;
17613
17614 case down:
17615 18626 tile+=4;
17616 18626 break;
17617
17618 case left:
17619 17275 tile+=8;
17620 17275 break;
17621
17622 case right:
17623 17520 tile+=12;
17624 17520 break;
17625 }
17626
17627 70295 tile+=f2;
17628 70295 }
17629 else
17630 {
17631
4/5
✓ Branch 0 taken 6148 times.
✓ Branch 1 taken 6702 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6921 times.
✓ Branch 4 taken 5410 times.
25181 switch(misc&3)
17632 {
17633 case down:
17634 6148 flip=2;
17635
17636 [[fallthrough]];
17637 case up:
17638 13069 tile=(clk3)?188:189;
17639 13069 break;
17640
17641 case right:
17642 6702 flip=1;
17643 [[fallthrough]];
17644
17645 case left:
17646 12112 tile=(clk3)?186:187;
17647 12112 break;
17648 }
17649 }
17650
17651 95476 enemy::draw(dest);
17652 95476 }
17653
17654 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
17655 168 {
17656
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if ( !(editorflags & ENEMY_FLAG5) )
17657 {
17658
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 x = 120;
17659
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 y = 48;
17660 84 }
17661 else
17662 {
17663 if ( !(editorflags & ENEMY_FLAG6) )
17664 {
17665 x = X; y = Y;
17666 }
17667 else
17668 {
17669 x = X+8; y = Y;
17670 }
17671 }
17672 84 hzsz = 32; // can't be jumped.
17673 84 flameclk=0;
17674 84 misc=clk; // total head count
17675 84 clk3=clk; // live head count
17676 84 clk=0;
17677 84 clk2=60; // fire ball clock
17678 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
17679
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 hp=(guysbuf[id&0xFFF].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
17680 84 dir = down;
17681 84 hxofs=4;
17682 84 hxsz=8;
17683 // frate=17*4;
17684 84 fading=fade_blue_poof;
17685 //nets+5420;
17686
3/4
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 19 times.
84 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17687 {
17688 /*
17689 necktile=o_tile+8;
17690 if (dmisc3)
17691 {
17692 necktile+=8;
17693 }
17694 */
17695 65 necktile=o_tile+dmisc6;
17696 65 }
17697 else
17698 {
17699 19 necktile=s_tile;
17700 }
17701 84 }
17702
17703 65287 bool eGleeok::animate(int32_t index)
17704 {
17705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65287 times.
65287 if(switch_hooked) return enemy::animate(index);
17706
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 64135 times.
65287 if(dying)
17707 1152 return Dead(index);
17708
17709
2/2
✓ Branch 0 taken 63843 times.
✓ Branch 1 taken 292 times.
64135 if(clk==0)
17710 {
17711 292 removearmos(x,y,ffcactivated);
17712 292 }
17713
17714 // Check if a head was killed somehow...
17715
2/2
✓ Branch 0 taken 34025 times.
✓ Branch 1 taken 30110 times.
64135 if(index+1+clk3>=guys.Count())
17716 30110 clk3=guys.Count()-index-1;
17717
2/2
✓ Branch 0 taken 13804 times.
✓ Branch 1 taken 50331 times.
64135 if(index+1+misc>=guys.Count())
17718 50331 misc=guys.Count()-index-1;
17719
17720 //fix for the "kill all enemies" item
17721
2/2
✓ Branch 0 taken 64129 times.
✓ Branch 1 taken 6 times.
64135 if(hp==-1000)
17722 {
17723
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
17724 {
17725 // I haven't seen this fail, but it seems like it ought to be
17726 // possible, so I'm checking for it. - Saf
17727
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
17728 break;
17729 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
17730 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
17731 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
17732 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
17733 12 }
17734
17735 6 clk3=0;
17736
17737
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
17738 {
17739
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
17740 break;
17741 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
17742 12 }
17743 6 }
17744
17745
2/2
✓ Branch 0 taken 148594 times.
✓ Branch 1 taken 64135 times.
212729 for(int32_t i=0; i<clk3; i++)
17746 {
17747 148594 enemy *head = ((enemy*)guys.spr(index+i+1));
17748 148594 head->dummy_int[1]=necktile;
17749 148594 head->parent_script_UID = this->script_UID;
17750
17751
2/2
✓ Branch 0 taken 98803 times.
✓ Branch 1 taken 49791 times.
148594 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17752 {
17753 98803 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
17754 98803 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
17755 98803 }
17756 else
17757 {
17758 49791 head->dummy_int[2]=necktile+1; //connected head tile
17759 49791 head->dummy_int[3]=necktile+2; //flying head tile
17760 }
17761
17762 148594 head->dmisc5=dmisc5; //neck segments
17763
17764 /*
17765 if (dmisc3)
17766 {
17767 head->dummy_bool[0]=true;
17768 }
17769 */
17770
2/2
✓ Branch 0 taken 146046 times.
✓ Branch 1 taken 2548 times.
148594 if(head->hclk)
17771 {
17772
2/2
✓ Branch 0 taken 2024 times.
✓ Branch 1 taken 524 times.
2548 if(hclk==0)
17773 {
17774 524 hp -= 1000 - head->hp;
17775 524 hclk = 33;
17776
17777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 524 times.
524 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
17778
17779 524 sfx(WAV_EHIT,pan(int32_t(head->x)));
17780 524 }
17781
17782 2548 head->hclk = 0;
17783 2548 }
17784
17785 // Must be set in case of naughty ZScripts
17786 148594 head->hp = 1000;
17787 148594 }
17788
17789
2/2
✓ Branch 0 taken 63958 times.
✓ Branch 1 taken 177 times.
64135 if(hp<=(guysbuf[id&0xFFF].misc2)*(clk3-1)*game->get_hero_dmgmult())
17790 {
17791 177 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
17792 177 hp=(guysbuf[id&0xFFF].misc2)*(--clk3)*game->get_hero_dmgmult();
17793 177 }
17794
17795
2/2
✓ Branch 0 taken 18578 times.
✓ Branch 1 taken 45557 times.
64135 if(!dmisc3)
17796 {
17797
4/4
✓ Branch 0 taken 2509 times.
✓ Branch 1 taken 43048 times.
✓ Branch 2 taken 615 times.
✓ Branch 3 taken 1894 times.
45557 if(++clk2>72 && !(zc_oldrand()&3))
17798 {
17799 615 int32_t i=zc_oldrand()%misc;
17800 615 enemy *head = ((enemy*)guys.spr(index+i+1));
17801 615 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
17802 615 sfx(wpnsfx(wpn),pan(int32_t(x)));
17803 615 clk2=0;
17804 615 }
17805 45557 }
17806 else
17807 {
17808
4/4
✓ Branch 0 taken 779 times.
✓ Branch 1 taken 17799 times.
✓ Branch 2 taken 598 times.
✓ Branch 3 taken 181 times.
18578 if(++clk2>100 && !(zc_oldrand()&3))
17809 {
17810 181 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
17811 181 head->timer=zc_oldrand()%50+50;
17812 181 clk2=0;
17813 181 }
17814 }
17815
17816
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64071 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64135 if((hp<=0 && !immortal))
17817 {
17818
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 64 times.
235 for(int32_t i=0; i<misc; i++)
17819 171 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
17820
17821
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 61 times.
64 if(flags&guy_neverret) never_return(index);
17822 64 }
17823
17824 64135 return enemy::animate(index);
17825 65287 }
17826
17827 150 int32_t eGleeok::takehit(weapon*,weapon*)
17828 {
17829 150 return 0;
17830 }
17831
17832 65605 void eGleeok::draw(BITMAP *dest)
17833 {
17834 65605 tile=o_tile;
17835
17836
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 64453 times.
65605 if(dying)
17837 {
17838 1152 enemy::draw(dest);
17839 1152 return;
17840 }
17841
17842 64453 int32_t f=clk/17;
17843
17844
2/2
✓ Branch 0 taken 43721 times.
✓ Branch 1 taken 20732 times.
64453 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17845 {
17846 // body
17847 43721 xofs=-8;
17848 43721 yofs=32;
17849
17850
4/4
✓ Branch 0 taken 33457 times.
✓ Branch 1 taken 3611 times.
✓ Branch 2 taken 3364 times.
✓ Branch 3 taken 3289 times.
43721 switch(f)
17851
17852 {
17853 case 0:
17854 3611 tile+=0;
17855 3611 break;
17856
17857 case 1:
17858 3364 tile+=2;
17859 3364 break;
17860
17861 case 2:
17862 3289 tile+=4;
17863 3289 break;
17864
17865 default:
17866 33457 tile+=6;
17867 33457 break;
17868 }
17869 43721 }
17870 else
17871 {
17872 // body
17873 20732 xofs=-8;
17874 20732 yofs=32;
17875
17876
3/3
✓ Branch 0 taken 17778 times.
✓ Branch 1 taken 1492 times.
✓ Branch 2 taken 1462 times.
20732 switch(f)
17877 {
17878 case 0:
17879 1492 tile+=0;
17880 1492 break;
17881
17882 case 2:
17883 1462 tile+=4;
17884 1462 break;
17885
17886 default:
17887 17778 tile+=2;
17888 17778 break;
17889 }
17890 }
17891
17892 64453 enemy::drawblock(dest,15);
17893 65605 }
17894
17895 65605 void eGleeok::draw2(BITMAP *dest)
17896 {
17897 // the neck stub
17898 65605 tile=necktile;
17899 65605 xofs=0;
17900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65605 times.
65605 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17901
17902
2/2
✓ Branch 0 taken 21074 times.
✓ Branch 1 taken 44531 times.
65605 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17903 {
17904 44531 tile+=((clk&24)>>3);
17905 44531 }
17906
17907
3/4
✓ Branch 0 taken 64453 times.
✓ Branch 1 taken 1152 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64453 times.
65605 if(hp > 0 && !dont_draw())
17908 {
17909
3/4
✓ Branch 0 taken 637 times.
✓ Branch 1 taken 63816 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 637 times.
64453 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
17910 sprite::drawcloaked(dest);
17911 else
17912 64453 sprite::draw(dest);
17913 64453 }
17914 65605 }
17915
17916
4/8
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 248 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 248 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 248 times.
✗ Branch 7 not taken.
744 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
17917 496 {
17918
1/2
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
248 xoffset=0;
17919
2/4
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 248 times.
✗ Branch 3 not taken.
248 yoffset=(zfix)((dmisc5*4+2));
17920 // dummy_bool[0]=false;
17921 248 timer=0;
17922 /* fixing */
17923 248 hp=1000;
17924
1/2
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
248 step=1;
17925 248 item_set=0;
17926 //x=120; y=70;
17927
4/8
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 248 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 248 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 248 times.
✗ Branch 7 not taken.
248 x = xoffset+parent->x;
17928
4/8
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 248 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 248 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 248 times.
✗ Branch 7 not taken.
248 y = yoffset+parent->y;
17929 248 hxofs=4;
17930 248 hxsz=8;
17931
3/6
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248 times.
✓ Branch 4 taken 248 times.
✗ Branch 5 not taken.
248 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17932 248 clk2=clk; // how int32_t to wait before moving first time
17933 248 clk=0;
17934 248 mainguy=count_enemy=false;
17935
1/2
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
248 dir=zc_oldrand();
17936 248 clk3=((dir&2)>>1)+2; // left or right
17937 248 dir&=1; // up or down
17938
1/2
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
248 dmisc5=vbound(dmisc5,1,255);
17939 248 isCore = false;
17940
1/2
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
248 parentCore = parent->getUID();
17941
2/2
✓ Branch 0 taken 992 times.
✓ Branch 1 taken 248 times.
1240 for(int32_t i=0; i<dmisc5; i++)
17942 {
17943 992 nxoffset[i] = 0;
17944 992 nyoffset[i] = 0;
17945
2/4
✓ Branch 0 taken 992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 992 times.
✗ Branch 3 not taken.
992 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
17946
2/4
✓ Branch 0 taken 992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 992 times.
✗ Branch 3 not taken.
992 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
17947 992 }
17948
17949 248 necktile=0;
17950 //TODO compatibility? -DD
17951 /*
17952 for(int32_t i=0; i<4; i++)
17953 {
17954 nx[i]=124;
17955 ny[i]=i*6+48;
17956 }*/
17957 248 bgsfx=-1;
17958 //no need for deadsfx
17959 248 }
17960
17961 191825 bool esGleeok::animate(int32_t index)
17962 {
17963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 191825 times.
191825 if(switch_hooked) return enemy::animate(index);
17964 // don't call removearmos() - it's a segment.
17965
17966 191825 dmisc5=vbound(dmisc5,1,255);
17967
17968
2/2
✓ Branch 0 taken 43402 times.
✓ Branch 1 taken 148423 times.
191825 if(misc == 0)
17969 {
17970 148423 x = (xoffset+parent->x);
17971 148423 y = (yoffset+parent->y);
17972
17973
2/2
✓ Branch 0 taken 593692 times.
✓ Branch 1 taken 148423 times.
742115 for(int32_t i=0; i<dmisc5; i++)
17974 {
17975 593692 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
17976 593692 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
17977 593692 }
17978 148423 }
17979
17980 // set up the head tiles
17981 // headtile=nets+5588; //5580, actually. must adjust for direction later on
17982 /*
17983 if (dummy_bool[0]) //if this is a flame gleeok
17984 {
17985 headtile+=180;
17986 }
17987 */
17988 191825 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
17989 191825 flyingheadtile=dummy_int[3];
17990
17991 // set up the neck tiles
17992 191825 necktile=dummy_int[1];
17993
17994
2/2
✓ Branch 0 taken 122856 times.
✓ Branch 1 taken 68969 times.
191825 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17995 {
17996 122856 necktile+=((clk&24)>>3);
17997 122856 }
17998
17999 /*
18000 else
18001 {
18002 necktile=145;
18003 }
18004 */
18005 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
18006
18007
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 148423 times.
✓ Branch 2 taken 43094 times.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 183 times.
191825 switch(misc)
18008 {
18009 case 0: // live head
18010 // set up the attached head tiles
18011 148423 tile=headtile;
18012
18013
2/2
✓ Branch 0 taken 98694 times.
✓ Branch 1 taken 49729 times.
148423 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18014 {
18015 98694 tile+=((clk&24)>>3);
18016 /*
18017 if (dummy_bool[0]) {
18018 tile+=1561;
18019 }
18020 */
18021 98694 }
18022
18023 /*
18024 else
18025 {
18026 tile=146;
18027 }
18028 */
18029
4/4
✓ Branch 0 taken 37857 times.
✓ Branch 1 taken 110566 times.
✓ Branch 2 taken 4201 times.
✓ Branch 3 taken 33656 times.
148423 if(++clk2>=0 && !(clk2&3))
18030 {
18031
2/2
✓ Branch 0 taken 32918 times.
✓ Branch 1 taken 738 times.
33656 if(y<= (int32_t)parent->y + 8) dir=down;
18032
18033
2/2
✓ Branch 0 taken 32959 times.
✓ Branch 1 taken 697 times.
33656 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
18034
18035
4/4
✓ Branch 0 taken 3518 times.
✓ Branch 1 taken 30138 times.
✓ Branch 2 taken 3422 times.
✓ Branch 3 taken 96 times.
33656 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
18036 {
18037 96 dir^=1;
18038 96 }
18039
18040 33656 zfix tempx = x;
18041 33656 zfix tempy = y;
18042
18043 33656 sprite::move(step);
18044 33656 xoffset += (x-tempx);
18045 33656 yoffset += (y-tempy);
18046
18047
2/2
✓ Branch 0 taken 1396 times.
✓ Branch 1 taken 32260 times.
33656 if(clk2>=4)
18048 {
18049 1396 clk3^=1;
18050 1396 clk2=-4;
18051 1396 }
18052 else
18053 {
18054
2/2
✓ Branch 0 taken 31930 times.
✓ Branch 1 taken 330 times.
32260 if(x <= (int32_t)parent->x-(dmisc5*6))
18055 {
18056 330 clk3=right;
18057 330 }
18058
18059
2/2
✓ Branch 0 taken 31903 times.
✓ Branch 1 taken 357 times.
32260 if(x >= (int32_t)parent->x+(dmisc5*6))
18060 {
18061 357 clk3=left;
18062 357 }
18063
18064
4/4
✓ Branch 0 taken 21757 times.
✓ Branch 1 taken 10503 times.
✓ Branch 2 taken 20438 times.
✓ Branch 3 taken 1319 times.
32260 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
18065 {
18066 1319 clk3^=1; // x jig
18067 1319 }
18068 else
18069 {
18070
4/4
✓ Branch 0 taken 10656 times.
✓ Branch 1 taken 20285 times.
✓ Branch 2 taken 10341 times.
✓ Branch 3 taken 315 times.
30941 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
18071 {
18072 315 clk3^=1; // x switch back
18073 315 }
18074
18075 30941 clk2=-4;
18076 }
18077 }
18078
18079 33656 zc_swap(dir,clk3);
18080 33656 tempx = x;
18081 33656 tempy = y;
18082 33656 sprite::move(step);
18083 33656 xoffset += (x-tempx);
18084 33656 yoffset += (y-tempy);
18085 33656 zc_swap(dir,clk3);
18086
18087
2/2
✓ Branch 0 taken 100968 times.
✓ Branch 1 taken 33656 times.
134624 for(int32_t i=1; i<dmisc5; i++)
18088 {
18089 100968 nxoffset[i] = (zc_oldrand()%3);
18090 100968 nyoffset[i] = (zc_oldrand()%3);
18091 100968 }
18092 33656 }
18093
18094 148423 break;
18095
18096 case 1: // flying head
18097
2/2
✓ Branch 0 taken 2599 times.
✓ Branch 1 taken 40495 times.
43094 if(clk>=0)
18098
18099 {
18100 40495 variable_walk_8(rate,homing,hrate,spw_floater);
18101 40495 }
18102
18103 43094 break;
18104
18105 // the following are messages sent from the main guy...
18106 case -1: // got chopped off
18107 {
18108 125 misc=1;
18109 125 superman=1;
18110 125 hxofs=xofs=0;
18111 125 hxsz=16;
18112 125 cs=8;
18113 125 clk=-24;
18114 125 clk2=40;
18115 125 dir=(zc_oldrand()&7)+8;
18116 125 step=8.0/9.0;
18117 }
18118 125 break;
18119
18120 case -2: // the big guy is dead
18121 183 return true;
18122 }
18123
18124
2/2
✓ Branch 0 taken 179316 times.
✓ Branch 1 taken 12326 times.
191642 if(timer)
18125 {
18126
2/2
✓ Branch 0 taken 10857 times.
✓ Branch 1 taken 1469 times.
12326 if(!(timer%8))
18127 {
18128 1469 FireBreath(true);
18129 1469 }
18130
18131 12326 --timer;
18132 12326 }
18133
18134 191642 return enemy::animate(index);
18135 191825 }
18136
18137 3184 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
18138 {
18139
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3184 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3184 if ((editorflags & ENEMY_FLAG7) && misc == 1)
18140 {
18141 int32_t wpnId = w->id;
18142
18143 if(dying)
18144 return 0;
18145
18146 switch(wpnId)
18147 {
18148 case wLitBomb:
18149 case wLitSBomb:
18150 case wBait:
18151 case wWhistle:
18152 case wFire:
18153 case wWind:
18154 case wSSparkle:
18155 case wFSparkle:
18156 case wPhantom:
18157 return 0;
18158
18159 case wHookshot:
18160 case wBrang:
18161 case wBeam:
18162 case wArrow:
18163 case wMagic:
18164 case wBomb:
18165 case wSBomb:
18166 sfx(WAV_CHINK,pan(int32_t(x)));
18167 break;
18168 default:
18169 break;
18170 }
18171
18172 return 1;
18173 }
18174 else
18175 {
18176 3184 int32_t ret = enemy::takehit(w,realweap);
18177
18178
2/2
✓ Branch 0 taken 636 times.
✓ Branch 1 taken 2548 times.
3184 if(ret==-1)
18179 2548 return 2; // force it to wait a frame before checking sword attacks again
18180
18181 636 return ret;
18182 }
18183 3184 }
18184
18185 192512 void esGleeok::draw(BITMAP *dest)
18186 {
18187 192512 dmisc5=vbound(dmisc5,1,255);
18188
18189
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 149305 times.
✓ Branch 2 taken 43207 times.
192512 switch(misc)
18190 {
18191 case 0: //neck
18192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149305 times.
149305 if(!dont_draw())
18193 {
18194
2/2
✓ Branch 0 taken 447915 times.
✓ Branch 1 taken 149305 times.
597220 for(int32_t i=1; i<dmisc5; i++) //draw the neck
18195 {
18196
2/2
✓ Branch 0 taken 298542 times.
✓ Branch 1 taken 149373 times.
447915 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18197 {
18198
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 298542 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
298542 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
18199 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0);
18200 else
18201 298542 overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0);
18202 298542 }
18203 else
18204 {
18205
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 145095 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4278 times.
149373 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
18206 overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0);
18207 else
18208 149373 overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0);
18209 }
18210 447915 }
18211 149305 }
18212
18213 149305 break;
18214
18215 case 1: //flying head
18216 43207 tile=flyingheadtile;
18217
18218
2/2
✓ Branch 0 taken 19178 times.
✓ Branch 1 taken 24029 times.
43207 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18219 {
18220 24029 tile+=((clk&24)>>3);
18221 24029 break;
18222 }
18223
18224 /*
18225 else
18226 {
18227 tile=(clk&1)?147:148;
18228 break;
18229 }
18230 */
18231 19178 }
18232 192512 }
18233
18234 192512 void esGleeok::draw2(BITMAP *dest)
18235 {
18236 192512 enemy::draw(dest);
18237 192512 }
18238
18239 100 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
18240 100 {
18241
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if ( !(editorflags & ENEMY_FLAG5) )
18242 {
18243
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 x = 128;
18244
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 y = 48;
18245 50 }
18246 else { x = X; y = Y; }
18247 50 adjusted=false;
18248
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 dir=(zc_oldrand()&7)+8;
18249 //step=0.25;
18250 50 flycnt=dmisc1;
18251 50 flycnt2=dmisc2;
18252 50 loopcnt=0;
18253 50 clk4 = 0;
18254 50 clk5 = 0;
18255 50 clk6 = 0;
18256 50 clk7 = 0;
18257
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
18258 50 SIZEflags = d->SIZEflags;
18259
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
50 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
18260
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
18261 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
18262 // al_trace("Enemy txsz:%i\n", txsz);
18263
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
50 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
18264
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
18265
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
18266
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 else if (dmisc10 == 1) hxsz = 32;
18267
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
18268
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
18269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
18270
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 else if (dmisc10 == 1) hxofs = -8;
18271
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
18272 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
18273
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
50 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
18274
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 else if (dmisc10 == 1) xofs = -8;
18275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
18276 {
18277 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
18278 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
18279 }
18280
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
50 else if (dmisc10 == 1) yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)-8;
18281
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if (editorflags & ENEMY_FLAG8) misc = 1;
18282
18283
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
50 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
18284
18285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if (dmisc29 == 0)
18286 {
18287
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 31 times.
50 if(!dmisc4)
18288 {
18289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (dmisc10) dmisc29 = (90 / 3);
18290 31 else dmisc29 = (84 / 3);
18291 31 }
18292 else
18293 {
18294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if (dmisc10) dmisc29 = (90 / 2);
18295 19 else dmisc29 = (84 / 2);
18296 }
18297 50 }
18298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if (dmisc30 == 0)
18299 {
18300
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 31 times.
50 if(!dmisc4)
18301 {
18302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (dmisc10) dmisc30 = (90 / 3)*0.5;
18303 31 else dmisc30 = (84 / 3)*0.5;
18304 31 }
18305 else
18306 {
18307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if (dmisc10) dmisc30 = (90 / 2)*0.5;
18308 19 else dmisc30 = (84 / 2)*0.5;
18309 }
18310 50 }
18311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if (dmisc31 == 0)
18312 {
18313
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 31 times.
50 if(!dmisc4)
18314 {
18315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (dmisc10) dmisc31 = (90 / 3)*2;
18316 31 else dmisc31 = (84 / 3)*2;
18317 31 }
18318 else
18319 {
18320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if (dmisc10) dmisc31 = (90 / 2)*0.5;
18321 19 else dmisc31 = (84 / 2)*0.5;
18322 }
18323 50 }
18324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if (dmisc32 == 0)
18325 {
18326
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 31 times.
50 if(!dmisc4)
18327 {
18328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (dmisc10) dmisc32 = (90 / 3);
18329 31 else dmisc32 = (84 / 3);
18330 31 }
18331 else
18332 {
18333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if (dmisc10) dmisc32 = (90 / 2)*0.25;
18334 19 else dmisc32 = (84 / 2)*0.25;
18335 }
18336 50 }
18337 50 }
18338
18339 60290 bool ePatra::animate(int32_t index)
18340 {
18341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60290 times.
60290 if(switch_hooked) return enemy::animate(index);
18342
2/2
✓ Branch 0 taken 774 times.
✓ Branch 1 taken 59516 times.
60290 if(dying)
18343 {
18344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 774 times.
774 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
18345 {
18346 ((enemy*)guys.spr(i))->hp = -1000;
18347 }
18348
18349 774 return Dead(index);
18350 }
18351
18352 59516 double basesize = 84;
18353
1/2
✓ Branch 0 taken 59516 times.
✗ Branch 1 not taken.
59516 if (dmisc10) basesize = 90;
18354 59516 double halfsize = basesize / 2;
18355 59516 double quartersize = halfsize / 2;
18356 59516 double twothirdsize = (basesize / 3)*2;
18357 59516 double onethirdsize = (basesize / 3);
18358
18359
18360
2/2
✓ Branch 0 taken 13168 times.
✓ Branch 1 taken 46348 times.
59516 if(clk==0)
18361 {
18362 13168 removearmos(x,y,ffcactivated);
18363 13168 }
18364
18365
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 59516 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 59516 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
59516 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
18366 {
18367
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 59516 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
59516 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
18368
1/2
✓ Branch 0 taken 59516 times.
✗ Branch 1 not taken.
59516 if (loopcnt < 0) ++clk2;
18369
2/2
✓ Branch 0 taken 58844 times.
✓ Branch 1 taken 672 times.
59516 if(++clk2>basesize)
18370 {
18371 672 clk2=0;
18372
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 672 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 672 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
672 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
18373 {
18374
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 323 times.
672 if(loopcnt > 0)
18375 349 --loopcnt;
18376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 323 times.
323 else if (loopcnt == 0)
18377 {
18378
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 123 times.
323 if((misc%dmisc6)==0)
18379 {
18380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if (dmisc21 > 0) loopcnt=-dmisc21;
18381 123 else loopcnt=dmisc7;
18382 123 }
18383 323 }
18384 else if (loopcnt == -1) loopcnt=dmisc7;
18385 else ++loopcnt;
18386
18387
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 672 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
672 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
18388 672 }
18389 else
18390 {
18391 loopcnt = 0;
18392 misc = 1;
18393 }
18394 672 }
18395 59516 }
18396
1/2
✓ Branch 0 taken 59516 times.
✗ Branch 1 not taken.
59516 if (clk4 > 0) --clk4;
18397
18398 59516 double size=1;
18399
18400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59516 times.
59516 if (clk6 < 0)
18401 {
18402 if (dmisc5 == 1 || dmisc5 == 3)
18403 {
18404 if (get_bit(quest_rules,qr_NEWENEMYTILES))
18405 {
18406 if (clk7 <= 0 || clk6 != -16) ++clk6;
18407 if (clk6 == 0) o_tile=d->e_tile;
18408 else
18409 {
18410 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
18411 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
18412 }
18413 }
18414 else clk6 = 0;
18415 }
18416 }
18417
1/2
✓ Branch 0 taken 59516 times.
✗ Branch 1 not taken.
59516 else if (dmisc19) ++clk6;
18418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59516 times.
59516 if (clk5 < 0) ++clk5;
18419
1/2
✓ Branch 0 taken 59516 times.
✗ Branch 1 not taken.
59516 else if (dmisc19) ++clk5;
18420
18421
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59516 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59516 if (clk7 > 0 && clk6 >= -16) --clk7;
18422
1/2
✓ Branch 0 taken 59516 times.
✗ Branch 1 not taken.
59516 if (clk6 > 0) clk7 = 0;
18423
18424
2/2
✓ Branch 0 taken 234048 times.
✓ Branch 1 taken 59516 times.
293564 for(int32_t i=index+1; i<index+flycnt+1; i++)
18425 {
18426 //outside ring
18427
2/2
✓ Branch 0 taken 233648 times.
✓ Branch 1 taken 400 times.
234048 if(!adjusted)
18428 {
18429
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 128 times.
400 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18430 {
18431 272 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
18432 272 enemy *s = ((enemy*)guys.spr(i));
18433 272 s->parent_script_UID = this->script_UID;
18434 272 }
18435 else
18436 {
18437 128 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
18438 128 enemy *s = ((enemy*)guys.spr(i));
18439 128 s->parent_script_UID = this->script_UID;
18440 }
18441
18442 400 ((enemy*)guys.spr(i))->cs=dmisc9;
18443 400 ((enemy*)guys.spr(i))->hp=dmisc3;
18444 400 }
18445
18446
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 233704 times.
234048 if(((enemy*)guys.spr(i))->hp <= 0)
18447 {
18448
2/2
✓ Branch 0 taken 1242 times.
✓ Branch 1 taken 344 times.
1586 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
18449 {
18450 1242 guys.swap(j,j+1);
18451 1242 }
18452
18453
3/4
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 301 times.
✓ Branch 2 taken 43 times.
✗ Branch 3 not taken.
344 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
18454 344 }
18455 else
18456 {
18457 233704 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
18458
1/2
✓ Branch 0 taken 233704 times.
✗ Branch 1 not taken.
233704 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
18459
18460
2/2
✓ Branch 0 taken 86815 times.
✓ Branch 1 taken 146889 times.
233704 if(!dmisc4) //Big Ring
18461 {
18462 //maybe playing_field_offset here?
18463
2/2
✓ Branch 0 taken 67383 times.
✓ Branch 1 taken 79506 times.
146889 if(loopcnt>0)
18464 {
18465
1/2
✓ Branch 0 taken 79506 times.
✗ Branch 1 not taken.
79506 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
18466
1/2
✓ Branch 0 taken 79506 times.
✗ Branch 1 not taken.
79506 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
18467 79506 }
18468 else
18469 {
18470 67383 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
18471 67383 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
18472 }
18473
18474 146889 temp_x=guys.spr(i)->x;
18475 146889 temp_y=guys.spr(i)->y;
18476 146889 }
18477 else //Oval
18478 {
18479 86815 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
18480 86815 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
18481
18482
2/2
✓ Branch 0 taken 50142 times.
✓ Branch 1 taken 36673 times.
86815 if(loopcnt>0)
18483 {
18484 50142 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
18485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50142 times.
50142 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
18486 50142 }
18487 else
18488 {
18489 36673 guys.spr(i)->x = circle_x;
18490 36673 guys.spr(i)->y = circle_y;
18491 }
18492
18493 86815 temp_x=circle_x;
18494 86815 temp_y=circle_y;
18495 }
18496
18497 double _MSVC2022_tmp1, _MSVC2022_tmp2;
18498 233704 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
18499
18500
4/4
✓ Branch 0 taken 44335 times.
✓ Branch 1 taken 189369 times.
✓ Branch 2 taken 14676 times.
✓ Branch 3 taken 29659 times.
233704 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
18501 {
18502 29659 guys.spr(i)->dir=l_down;
18503 29659 }
18504
4/4
✓ Branch 0 taken 44369 times.
✓ Branch 1 taken 159676 times.
✓ Branch 2 taken 14676 times.
✓ Branch 3 taken 29693 times.
204045 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
18505 {
18506 29693 guys.spr(i)->dir=left;
18507 29693 }
18508
4/4
✓ Branch 0 taken 44118 times.
✓ Branch 1 taken 130234 times.
✓ Branch 2 taken 14676 times.
✓ Branch 3 taken 29442 times.
174352 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
18509 {
18510 29442 guys.spr(i)->dir=l_up;
18511 29442 }
18512
4/4
✓ Branch 0 taken 43786 times.
✓ Branch 1 taken 101124 times.
✓ Branch 2 taken 14676 times.
✓ Branch 3 taken 29110 times.
144910 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
18513 {
18514 29110 guys.spr(i)->dir=up;
18515 29110 }
18516
4/4
✓ Branch 0 taken 43559 times.
✓ Branch 1 taken 72241 times.
✓ Branch 2 taken 14676 times.
✓ Branch 3 taken 28883 times.
115800 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
18517 {
18518 28883 guys.spr(i)->dir=r_up;
18519 28883 }
18520
4/4
✓ Branch 0 taken 43421 times.
✓ Branch 1 taken 43496 times.
✓ Branch 2 taken 14676 times.
✓ Branch 3 taken 28745 times.
86917 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
18521 {
18522 28745 guys.spr(i)->dir=right;
18523 28745 }
18524
4/4
✓ Branch 0 taken 43525 times.
✓ Branch 1 taken 14647 times.
✓ Branch 2 taken 14676 times.
✓ Branch 3 taken 28849 times.
58172 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
18525 {
18526 28849 guys.spr(i)->dir=r_down;
18527 28849 }
18528 else
18529 {
18530 29323 guys.spr(i)->dir=down;
18531 }
18532
18533 233704 guys.spr(i)->x += x;
18534 233704 guys.spr(i)->y += y;
18535 }
18536 234048 }
18537
18538
7/22
✓ Branch 0 taken 37900 times.
✓ Branch 1 taken 21616 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37900 times.
✓ Branch 4 taken 5813 times.
✓ Branch 5 taken 15803 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5813 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 15803 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
59516 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
18539 {
18540 15803 int timeneeded = 48;
18541 15803 int patbreath = (zc_oldrand()%50+50);
18542
2/2
✓ Branch 0 taken 11961 times.
✓ Branch 1 taken 3842 times.
15803 if ((patbreath % 4) == 0) ++patbreath;
18543
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratBREATH)
18544 {
18545 timeneeded = 48 + patbreath;
18546 }
18547
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratSTREAM)
18548 {
18549 timeneeded = 48 + 96;
18550 }
18551
4/14
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15803 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 133 times.
✓ Branch 11 taken 133 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
15803 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
18552
2/2
✓ Branch 0 taken 15803 times.
✓ Branch 1 taken 133 times.
15936 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
18553
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 15670 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15936 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES))
18554 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)))))
18555 133 && (clk6 >= 0) //if not in the middle of firing...
18556 133 && clk6 >= dmisc19) //if over the set cooldown between shots...
18557
2/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 133 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
133 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
18558 {
18559
1/3
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
133 switch(dmisc28)
18560 {
18561 case patratSTREAM:
18562 {
18563 clk7 = 97;
18564 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)) clk6 = -48;
18565 else clk6 = 0;
18566 break;
18567 }
18568 case patratBREATH:
18569 {
18570 clk7 = patbreath;
18571 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)) clk6 = -48;
18572 else clk6 = 0;
18573 break;
18574 }
18575 default:
18576 {
18577
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18578 {
18579 clk6 = -48;
18580 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18581 }
18582 else
18583 {
18584 133 clk6 = 0;
18585
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18586 133 FirePatraWeapon();
18587 }
18588 133 break;
18589 }
18590 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
18591 133 }
18592
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (clk6 < 0)
18593 {
18594 switch(dmisc28)
18595 {
18596 case patratSTREAM:
18597 {
18598 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
18599 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18600 break;
18601 }
18602 case patratBREATH:
18603 {
18604 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
18605 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18606 break;
18607 }
18608 default:
18609 {
18610 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) && clk6 == -16)
18611 {
18612 FirePatraWeapon();
18613 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18614 }
18615 break;
18616 }
18617 }
18618 }
18619 15803 }
18620
18621 59516 size=.5;
18622 59516 int randattempts = 0;
18623 59516 int randeye = 0;
18624
2/2
✓ Branch 0 taken 42914 times.
✓ Branch 1 taken 16602 times.
59516 if (flycnt2 > 0)
18625 {
18626 16602 do
18627 {
18628
2/4
✓ Branch 0 taken 16602 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16602 times.
16602 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
18629 16602 randeye += (index + flycnt + 1);
18630 16602 ++randattempts;
18631
2/4
✓ Branch 0 taken 16602 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16602 times.
16602 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
18632 16602 }
18633 59516 bool dofire = false;
18634
1/2
✓ Branch 0 taken 59516 times.
✗ Branch 1 not taken.
59516 if (dmisc20)
18635 {
18636 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
18637 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
18638 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
18639 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) || dmisc20 == 2))
18640 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
18641 {
18642 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES))
18643 {
18644 if (clk5 >= dmisc19)
18645 {
18646 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
18647 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
18648 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
18649 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
18650 || dmisc18 == -1)
18651 dofire = true;
18652 }
18653 }
18654 }
18655 }
18656
2/2
✓ Branch 0 taken 42914 times.
✓ Branch 1 taken 16602 times.
59516 if(flycnt2)
18657 {
18658
2/2
✓ Branch 0 taken 119975 times.
✓ Branch 1 taken 16602 times.
136577 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
18659 {
18660
2/2
✓ Branch 0 taken 119887 times.
✓ Branch 1 taken 88 times.
119975 if(!adjusted)
18661 {
18662 88 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
18663
18664
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18665 {
18666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if (get_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS))
18667 {
18668
2/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
88 switch(dmisc5)
18669 {
18670 // Center eye shoots projectiles; make room for its firing tiles
18671 case 1:
18672 case 3:
18673 48 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
18674 48 break;
18675
18676 // Center eyes does not shoot; use tiles two rows below for inner eyes.
18677 default:
18678 case 2:
18679 40 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
18680 40 break;
18681 }
18682 88 }
18683 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
18684 88 }
18685 else
18686 {
18687 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
18688 }
18689
18690 88 ((enemy*)guys.spr(i))->cs=dmisc9;
18691
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
18692 88 }
18693
18694
2/2
✓ Branch 0 taken 94136 times.
✓ Branch 1 taken 25839 times.
119975 if(flycnt>0)
18695 {
18696 94136 ((enemy*)guys.spr(i))->superman=true;
18697 94136 }
18698 else
18699 {
18700 25839 ((enemy*)guys.spr(i))->superman=false;
18701 }
18702
18703
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 119903 times.
119975 if(((enemy*)guys.spr(i))->hp <= 0)
18704 {
18705
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 72 times.
216 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
18706 {
18707 144 guys.swap(j,j+1);
18708 144 }
18709
18710
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
72 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
18711 72 }
18712 else
18713 {
18714 119903 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
18715
1/2
✓ Branch 0 taken 119903 times.
✗ Branch 1 not taken.
119903 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
18716
18717
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 112644 times.
119903 if(dmisc4==0)
18718 {
18719
2/2
✓ Branch 0 taken 58268 times.
✓ Branch 1 taken 54376 times.
112644 if(loopcnt>0)
18720 {
18721
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
18722
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
18723 58268 }
18724 else
18725 {
18726 54376 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
18727 54376 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
18728 }
18729
18730 112644 temp_x=guys.spr(i)->x;
18731 112644 temp_y=guys.spr(i)->y;
18732 112644 }
18733 else
18734 {
18735 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
18736 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
18737
18738
2/2
✓ Branch 0 taken 3294 times.
✓ Branch 1 taken 3965 times.
7259 if(loopcnt>0)
18739 {
18740 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
18741
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
18742 3965 }
18743 else
18744 {
18745 3294 guys.spr(i)->x = circle_x;
18746 3294 guys.spr(i)->y = circle_y;
18747 }
18748
18749 7259 temp_x=circle_x;
18750 7259 temp_y=circle_y;
18751 }
18752
18753 double _MSVC2022_tmp1, _MSVC2022_tmp2;
18754 119903 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
18755
18756
4/4
✓ Branch 0 taken 22203 times.
✓ Branch 1 taken 97700 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14941 times.
119903 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
18757 {
18758 14941 guys.spr(i)->dir=l_down;
18759 14941 }
18760
4/4
✓ Branch 0 taken 22190 times.
✓ Branch 1 taken 82772 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14928 times.
104962 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
18761 {
18762 14928 guys.spr(i)->dir=left;
18763 14928 }
18764
4/4
✓ Branch 0 taken 22199 times.
✓ Branch 1 taken 67835 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14937 times.
90034 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
18765 {
18766 14937 guys.spr(i)->dir=l_up;
18767 14937 }
18768
4/4
✓ Branch 0 taken 22258 times.
✓ Branch 1 taken 52839 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14996 times.
75097 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
18769 {
18770 14996 guys.spr(i)->dir=up;
18771 14996 }
18772
4/4
✓ Branch 0 taken 22303 times.
✓ Branch 1 taken 37798 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15041 times.
60101 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
18773 {
18774 15041 guys.spr(i)->dir=r_up;
18775 15041 }
18776
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 22763 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
45060 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
18777 {
18778 15035 guys.spr(i)->dir=right;
18779 15035 }
18780
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 7728 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
30025 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
18781 {
18782 15035 guys.spr(i)->dir=r_down;
18783 15035 }
18784 else
18785 {
18786 14990 guys.spr(i)->dir=down;
18787 }
18788
18789 119903 guys.spr(i)->x += x;
18790 119903 guys.spr(i)->y = y-guys.spr(i)->y;
18791
18792
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 119903 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 81826 times.
✓ Branch 5 taken 38077 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 81826 times.
119903 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
18793 {
18794 /*
18795 if(!(zc_oldrand()&127))
18796 {
18797 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
18798 sfx(wpnsfx(wpn),pan(int32_t(x)));
18799 }
18800 */
18801
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38077 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
18802 {
18803 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
18804 if (get_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS))
18805 {
18806 if (dmisc5 == 3)
18807 {
18808 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
18809 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
18810 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
18811 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
18812 }
18813 else
18814 {
18815 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
18816 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
18817 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
18818 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
18819 }
18820 }
18821 else
18822 {
18823 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
18824 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
18825 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
18826 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
18827 }
18828 }
18829
4/6
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 38077 times.
✓ Branch 4 taken 38077 times.
✓ Branch 5 taken 38077 times.
38077 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
18830
1/2
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
38077 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
18831
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
18832 {
18833
1/5
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
38077 switch(dmisc20) //Patra Attack Patterns
18834 {
18835 case 4: //Single one rapidfires
18836 {
18837 if (dofire && i == randeye)
18838 {
18839 ((esPatra*)guys.spr(i))->clk5 = -16;
18840 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
18841 ((esPatra*)guys.spr(i))->clk4 = 96;
18842 clk5 = -3;
18843 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
18844 }
18845 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
18846 {
18847 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18848 sfx(wpnsfx(wpn),pan(int32_t(x)));
18849 }
18850 break;
18851 }
18852 case 3: //Ring
18853 {
18854 if (dofire)
18855 {
18856 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18857 {
18858 ((esPatra*)guys.spr(i))->clk5 = -48;
18859 clk5 = -48;
18860 if (editorflags & ENEMY_FLAG6) clk4 = 64;
18861 }
18862 else
18863 {
18864 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18865 sfx(wpnsfx(wpn),pan(int32_t(x)));
18866 int32_t m=Ewpns.Count()-1;
18867 weapon *ew = (weapon*)(Ewpns.spr(m));
18868
18869 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
18870 ((esPatra*)guys.spr(i))->clk5 = 0;
18871 clk5 = 0;
18872 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18873 }
18874 }
18875 if (((esPatra*)guys.spr(i))->clk5 == -16)
18876 {
18877 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18878 sfx(wpnsfx(wpn),pan(int32_t(x)));
18879 int32_t m=Ewpns.Count()-1;
18880 weapon *ew = (weapon*)(Ewpns.spr(m));
18881
18882 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
18883 }
18884 break;
18885 }
18886 case 2: //one after another
18887 {
18888 if (dofire)
18889 {
18890 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
18891 clk5 = -48 - (12*flycnt2);
18892 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
18893 }
18894 if (((esPatra*)guys.spr(i))->clk5 == -16)
18895 {
18896 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18897 sfx(wpnsfx(wpn),pan(int32_t(x)));
18898 }
18899 break;
18900 }
18901 case 1: //random one eye
18902 {
18903 if (dofire && i == randeye)
18904 {
18905 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18906 {
18907 ((esPatra*)guys.spr(i))->clk5 = -48;
18908 clk5 = -48;
18909 if (editorflags & ENEMY_FLAG6) clk4 = 64;
18910 }
18911 else
18912 {
18913 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18914 sfx(wpnsfx(wpn),pan(int32_t(x)));
18915 ((esPatra*)guys.spr(i))->clk5 = 0;
18916 clk5 = 0;
18917 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18918 }
18919 }
18920 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
18921 {
18922 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18923 sfx(wpnsfx(wpn),pan(int32_t(x)));
18924 }
18925 break;
18926 }
18927 default: //old behavior, all eyes can fire any time
18928 {
18929
3/8
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 292 times.
✓ Branch 5 taken 292 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
18930
3/6
✓ Branch 0 taken 38077 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 292 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES))
18931
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
18932 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
18933 {
18934
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18935 {
18936 ((esPatra*)guys.spr(i))->clk5 = -48;
18937 if (editorflags & ENEMY_FLAG6) clk4 = 64;
18938 }
18939 else
18940 {
18941 292 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
18942 292 sfx(wpnsfx(wpn),pan(int32_t(x)));
18943 292 ((esPatra*)guys.spr(i))->clk5 = 0;
18944
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18945 }
18946 292 }
18947
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
18948 {
18949 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
18950 sfx(wpnsfx(wpn),pan(int32_t(x)));
18951 }
18952 38077 break;
18953 }
18954 }
18955 38077 }
18956 38077 }
18957
18958 }
18959 119975 }
18960 16602 }
18961
18962 59516 adjusted=true;
18963 59516 return enemy::animate(index);
18964 60290 }
18965
18966 133 void ePatra::FirePatraWeapon()
18967 { //.707
18968 133 int32_t xoff = 0;
18969 133 int32_t yoff = 0;
18970
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
18971 {
18972 xoff += (hxsz/2)-8;
18973 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
18974 }
18975
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
18976 {
18977 yoff += (hysz/2)-8;
18978 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
18979 }
18980 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
18981
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
133 switch (dmisc28)
18982 {
18983 case patrat8SHOT: //Fire Wizzrobe
18984 case patrat4SHOTDIAG:
18985 case patrat4SHOTRAND:
18986 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
18987 {
18988 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
18989 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
18990 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
18991 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
18992
18993 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
18994 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
18995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
18996 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
18997
18998 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
18999 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19000 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19001 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
19002
19003 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
19004 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19005 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19006 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
19007
19008 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
19009 }
19010
19011 [[fallthrough]];
19012 case patrat4SHOTCARD: //Stalfos 3
19013 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
19014 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19015 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19016 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
19017 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19018 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19019 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
19020 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19021 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19022 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
19023 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19024 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19025 break;
19026
19027 default:
19028 133 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19029
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
19030 133 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
19031
3/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
133 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19032
4/8
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 133 times.
133 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
19033 {
19034 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19035 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
19036 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
19037 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19038 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19039 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
19040 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
19041 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19042 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
19043 {
19044 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19045 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
19046 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
19047 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19048 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19049 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
19050 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
19051 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19052 }
19053 }
19054 133 break;
19055
19056 }
19057 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
19058 //+0.46364761
19059 //11.80
19060 133 }
19061
19062 120774 void ePatra::draw(BITMAP *dest)
19063 {
19064 120774 tile=o_tile;
19065 120774 update_enemy_frame();
19066 120774 enemy::draw(dest);
19067 120774 }
19068
19069 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
19070 {
19071 int32_t ret = enemy::defend(wpnId, power, edef);
19072
19073 if(ret < 0 && (flycnt||flycnt2))
19074 return 0;
19075
19076 return ret;
19077 }
19078
19079 905 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
19080 {
19081 905 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
19082
19083
6/6
✓ Branch 0 taken 802 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 394 times.
✓ Branch 3 taken 408 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 142 times.
905 if(ret < 0 && (flycnt||flycnt2))
19084 660 return 0;
19085
19086 245 return ret;
19087 905 }
19088
19089 1464 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
19090 976 {
19091 //cs=8;
19092 488 item_set=0;
19093 488 misc=clk;
19094 488 clk4 = 0;
19095 488 clk5 = 0;
19096 488 clk = -((misc*21)>>1)-1;
19097
3/6
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 488 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 488 times.
✗ Branch 5 not taken.
488 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
19098 488 hxsz=12;
19099 488 hysz=12;
19100 488 hxofs=2;
19101 488 hyofs=2;
19102 488 extend = 0;
19103 488 txsz = 1;
19104 488 tysz = 1;
19105 /* //These need to be separate enemy editor fields. This enemy class also it's draw altered to correctly support big stuff.
19106 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
19107 int32_t prntSIZEflags = prntenemy->SIZEflags;
19108 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
19109 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
19110 // al_trace("Enemy txsz:%i\n", txsz);
19111 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
19112 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
19113 else
19114 hxsz=12;
19115 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
19116 else
19117 hysz=12;
19118 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
19119 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
19120 else
19121 hxofs=2;
19122 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
19123 else hyofs=2;
19124 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
19125 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
19126 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
19127 {
19128 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
19129 }
19130
19131 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
19132 */
19133 488 mainguy=count_enemy=false;
19134 488 bgsfx=-1;
19135 //o_tile=0;
19136 488 flags &= (~guy_neverret);
19137 488 deadsfx = WAV_EDEAD;
19138 488 hitsfx = WAV_EHIT;
19139 488 isCore = false;
19140 488 }
19141
19142 361789 bool esPatra::animate(int32_t index)
19143 {
19144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 361789 times.
361789 if(switch_hooked) return enemy::animate(index);
19145
2/2
✓ Branch 0 taken 7488 times.
✓ Branch 1 taken 354301 times.
361789 if(dying)
19146 7488 return Dead(index);
19147
19148 354301 return enemy::animate(index);
19149 361789 }
19150
19151 726330 void esPatra::draw(BITMAP *dest)
19152 {
19153
2/2
✓ Branch 0 taken 544720 times.
✓ Branch 1 taken 181610 times.
726330 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19154 {
19155 544720 tile = o_tile+(clk&3);
19156
19157
8/9
✓ Branch 0 taken 67770 times.
✓ Branch 1 taken 69066 times.
✓ Branch 2 taken 67800 times.
✓ Branch 3 taken 67996 times.
✓ Branch 4 taken 67484 times.
✓ Branch 5 taken 68044 times.
✓ Branch 6 taken 68474 times.
✓ Branch 7 taken 68086 times.
✗ Branch 8 not taken.
544720 switch(dir) //directions get screwed up after 8. *shrug*
19158 {
19159 case up: //u
19160 67770 flip=0;
19161 67770 break;
19162
19163 case down: //d
19164 69066 flip=0;
19165 69066 tile+=4;
19166 69066 break;
19167
19168 case left: //l
19169 67800 flip=0;
19170 67800 tile+=8;
19171 67800 break;
19172
19173 case right: //r
19174 67996 flip=0;
19175 67996 tile+=12;
19176 67996 break;
19177
19178 case l_up: //ul
19179 67484 flip=0;
19180 67484 tile+=20;
19181 67484 break;
19182
19183 case r_up: //ur
19184 68044 flip=0;
19185 68044 tile+=24;
19186 68044 break;
19187
19188 case l_down: //dl
19189 68474 flip=0;
19190 68474 tile+=28;
19191 68474 break;
19192
19193 case r_down: //dr
19194 68086 flip=0;
19195 68086 tile+=32;
19196 68086 break;
19197 }
19198 544720 }
19199 else
19200 {
19201 181610 tile = o_tile+((clk&2)>>1);
19202 }
19203
19204
2/2
✓ Branch 0 taken 36568 times.
✓ Branch 1 taken 689762 times.
726330 if(clk>=0)
19205 689762 enemy::draw(dest);
19206 726330 }
19207
19208
19209 6 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
19210 6 {
19211 3 adjusted=false;
19212
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dir=(zc_oldrand()&7)+8;
19213
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 step=0.25;
19214 3 clk4 = 0;
19215 3 clk5 = 0;
19216 //flycnt=6; flycnt2=0;
19217 3 flycnt=dmisc1;
19218 3 flycnt2=0; // PatraBS doesn't have inner rings!
19219 3 loopcnt=0;
19220
19221 3 SIZEflags = d->SIZEflags;
19222
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
19223 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
19224 // al_trace("Enemy txsz:%i\n", txsz);
19225
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
19226
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
19227 3 else hxsz = 32;
19228
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
19229
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
19230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
19231 3 else hxofs=-8;
19232
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
19233 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
19234
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
19235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
19236 {
19237 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
19238 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
19239 }
19240
19241
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
19242
19243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
19244
19245 //nets+4480;
19246 3 }
19247
19248 1862 bool ePatraBS::animate(int32_t index)
19249 {
19250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1862 times.
1862 if(switch_hooked) return enemy::animate(index);
19251
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1808 times.
1862 if(dying)
19252 54 return Dead(index);
19253
19254
2/2
✓ Branch 0 taken 1366 times.
✓ Branch 1 taken 442 times.
1808 if(clk==0)
19255 {
19256 442 removearmos(x,y,ffcactivated);
19257 442 }
19258
19259 1808 variable_walk_8(rate,homing,hrate,spw_floater);
19260
19261
2/2
✓ Branch 0 taken 1789 times.
✓ Branch 1 taken 19 times.
1808 if(++clk2>90)
19262 {
19263 19 clk2=0;
19264
19265
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 7 times.
19 if(loopcnt)
19266 12 --loopcnt;
19267 else
19268 {
19269
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if((misc%dmisc6)==0)
19270 4 loopcnt=dmisc7;
19271 }
19272
19273 19 ++misc;
19274 19 }
19275
19276 // double size=1;;
19277
2/2
✓ Branch 0 taken 4455 times.
✓ Branch 1 taken 1808 times.
6263 for(int32_t i=index+1; i<index+flycnt+1; i++)
19278 {
19279
2/2
✓ Branch 0 taken 4437 times.
✓ Branch 1 taken 18 times.
4455 if(!adjusted)
19280 {
19281 18 ((enemy*)guys.spr(i))->hp=dmisc3;
19282
19283
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19284 {
19285 18 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
19286 18 }
19287 else
19288 {
19289 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
19290 }
19291
19292 18 ((enemy*)guys.spr(i))->cs = dmisc9;
19293 18 }
19294
19295
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 4437 times.
4455 if(((enemy*)guys.spr(i))->hp <= 0)
19296 {
19297
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 18 times.
44 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
19298 {
19299 26 guys.swap(j,j+1);
19300 26 }
19301
19302 18 --flycnt;
19303 18 }
19304 else
19305 {
19306 4437 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
19307
1/2
✓ Branch 0 taken 4437 times.
✗ Branch 1 not taken.
4437 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
19308 4437 temp_x = zc::math::Cos(a2+PI/2)*45;
19309 4437 temp_y = -zc::math::Sin(a2+PI/2)*45;
19310
19311
2/2
✓ Branch 0 taken 2305 times.
✓ Branch 1 taken 2132 times.
4437 if(loopcnt>0)
19312 {
19313 2305 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
19314
1/2
✓ Branch 0 taken 2305 times.
✗ Branch 1 not taken.
2305 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
19315 2305 }
19316 else
19317 {
19318 2132 guys.spr(i)->x = temp_x;
19319 2132 guys.spr(i)->y = temp_y;
19320 }
19321
19322 double _MSVC2022_tmp1, _MSVC2022_tmp2;
19323 4437 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
19324
19325
4/4
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 3576 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 551 times.
4437 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
19326 {
19327 551 guys.spr(i)->dir=l_down;
19328 551 }
19329
4/4
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 3042 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 534 times.
3886 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
19330 {
19331 534 guys.spr(i)->dir=left;
19332 534 }
19333
4/4
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 2520 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 522 times.
3352 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
19334 {
19335 522 guys.spr(i)->dir=l_up;
19336 522 }
19337
4/4
✓ Branch 0 taken 874 times.
✓ Branch 1 taken 1956 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 564 times.
2830 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
19338 {
19339 564 guys.spr(i)->dir=up;
19340 564 }
19341
4/4
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1411 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 545 times.
2266 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
19342 {
19343 545 guys.spr(i)->dir=r_up;
19344 545 }
19345
4/4
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 849 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 562 times.
1721 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
19346 {
19347 562 guys.spr(i)->dir=right;
19348 562 }
19349
4/4
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 554 times.
1159 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
19350 {
19351 554 guys.spr(i)->dir=r_down;
19352 554 }
19353 else
19354 {
19355 605 guys.spr(i)->dir=down;
19356 }
19357
19358 4437 guys.spr(i)->x += x;
19359 4437 guys.spr(i)->y += y;
19360 }
19361 4455 }
19362
19363 1808 adjusted=true;
19364 1808 return enemy::animate(index);
19365 1862 }
19366
19367 3724 void ePatraBS::draw(BITMAP *dest)
19368 {
19369 3724 tile=o_tile;
19370
19371
1/2
✓ Branch 0 taken 3724 times.
✗ Branch 1 not taken.
3724 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19372 {
19373 double _MSVC2022_tmp1, _MSVC2022_tmp2;
19374 3724 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
19375
19376
4/4
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 3320 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 102 times.
3724 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
19377 {
19378 102 lookat=l_down;
19379 102 }
19380
4/4
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 3010 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 310 times.
3622 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
19381 {
19382 310 lookat=down;
19383 310 }
19384
4/4
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 2058 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 952 times.
3312 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
19385 {
19386 952 lookat=r_down;
19387 952 }
19388
4/4
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 1686 times.
2360 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
19389 {
19390 1686 lookat=right;
19391 1686 }
19392
4/4
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 180 times.
674 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
19393 {
19394 180 lookat=r_up;
19395 180 }
19396
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
494 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
19397 {
19398 lookat=up;
19399 }
19400
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
494 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
19401 {
19402 lookat=l_up;
19403 }
19404 else
19405 {
19406 494 lookat=left;
19407 }
19408
19409
6/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 494 times.
✓ Branch 4 taken 1686 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 180 times.
✓ Branch 7 taken 102 times.
✓ Branch 8 taken 952 times.
3724 switch(lookat) //directions get screwed up after 8. *shrug*
19410 {
19411 case up: //u
19412 flip=0;
19413 break;
19414
19415 case down: //d
19416 310 flip=0;
19417 310 tile+=8;
19418 310 break;
19419
19420 case left: //l
19421 494 flip=0;
19422 494 tile+=40;
19423 494 break;
19424
19425 case right: //r
19426 1686 flip=0;
19427 1686 tile+=48;
19428 1686 break;
19429
19430 case l_up: //ul
19431 flip=0;
19432 tile+=80;
19433 break;
19434
19435 case r_up: //ur
19436 180 flip=0;
19437 180 tile+=88;
19438 180 break;
19439
19440 case l_down: //dl
19441 102 flip=0;
19442 102 tile+=120;
19443 102 break;
19444
19445 case r_down: //dr
19446 952 flip=0;
19447 952 tile+=128;
19448 952 break;
19449 }
19450
19451 3724 tile+=(2*(clk&3));
19452 3724 xofs-=8;
19453 3724 yofs-=8;
19454 3724 drawblock(dest,15);
19455 3724 xofs+=8;
19456 3724 yofs+=8;
19457 3724 }
19458 else
19459 {
19460 flip=(clk&1);
19461 xofs-=8;
19462 yofs-=8;
19463 enemy::draw(dest);
19464 xofs+=16;
19465 enemy::draw(dest);
19466 yofs+=16;
19467 enemy::draw(dest);
19468 xofs-=16;
19469 enemy::draw(dest);
19470 xofs+=8;
19471 yofs-=8;
19472 }
19473 3724 }
19474
19475 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
19476 {
19477 int32_t ret = enemy::defend(wpnId, power, edef);
19478
19479 if(ret < 0 && (flycnt||flycnt2))
19480 return 0;
19481
19482 return ret;
19483 }
19484
19485 25 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
19486 {
19487 25 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
19488
19489
4/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
25 if(ret < 0 && (flycnt||flycnt2))
19490 19 return 0;
19491
19492 6 return ret;
19493 25 }
19494
19495 54 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
19496 36 {
19497 //cs=csBOSS;
19498 18 item_set=0;
19499 18 misc=clk;
19500 18 clk = -((misc*21)>>1)-1;
19501 18 clk4 = 0;
19502 18 clk5 = 0;
19503
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
19504 18 int32_t prntSIZEflags = prntenemy->SIZEflags;
19505
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
19506 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
19507 // al_trace("Enemy txsz:%i\n", txsz);
19508
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
19509
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
19510 18 else hxsz=16;
19511
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
19512 18 else hysz=16;
19513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
19514
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
19515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
19516 18 else hyofs=2;
19517 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
19518
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
19519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
19520 {
19521 yofs = (int32_t)prntenemy->yofs;
19522 }
19523
3/6
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
18 else yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
19524
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
19525
19526 18 bgsfx=-1;
19527 18 mainguy=count_enemy=false;
19528 18 deadsfx = WAV_EDEAD;
19529 18 hitsfx = WAV_EHIT;
19530 18 flags &= ~guy_neverret;
19531 18 isCore = false;
19532 18 }
19533
19534 4790 bool esPatraBS::animate(int32_t index)
19535 {
19536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4790 times.
4790 if(switch_hooked) return enemy::animate(index);
19537
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 4466 times.
4790 if(dying)
19538 324 return Dead(index);
19539
19540 4466 return enemy::animate(index);
19541 4790 }
19542
19543 9580 void esPatraBS::draw(BITMAP *dest)
19544 {
19545 9580 tile=o_tile;
19546
19547
1/2
✓ Branch 0 taken 9580 times.
✗ Branch 1 not taken.
9580 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19548 {
19549
8/9
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 1326 times.
✓ Branch 2 taken 1076 times.
✓ Branch 3 taken 1254 times.
✓ Branch 4 taken 1080 times.
✓ Branch 5 taken 1238 times.
✓ Branch 6 taken 1146 times.
✓ Branch 7 taken 1180 times.
✗ Branch 8 not taken.
9580 switch(dir) //directions get screwed up after 8. *shrug*
19550 {
19551 case up: //u
19552 1280 flip=0;
19553 1280 break;
19554
19555 case down: //d
19556 1326 flip=0;
19557 1326 tile+=4;
19558 1326 break;
19559
19560 case left: //l
19561 1076 flip=0;
19562 1076 tile+=8;
19563 1076 break;
19564
19565 case right: //r
19566 1254 flip=0;
19567 1254 tile+=12;
19568 1254 break;
19569
19570 case l_up: //ul
19571 1080 flip=0;
19572 1080 tile+=20;
19573 1080 break;
19574
19575 case r_up: //ur
19576 1238 flip=0;
19577 1238 tile+=24;
19578 1238 break;
19579
19580 case l_down: //dl
19581 1146 flip=0;
19582 1146 tile+=28;
19583 1146 break;
19584
19585 case r_down: //dr
19586 1180 flip=0;
19587 1180 tile+=32;
19588 1180 break;
19589 }
19590
19591 9580 tile += ((clk&6)>>1);
19592 9580 }
19593 else
19594 {
19595 tile += (clk&4)?1:0;
19596 }
19597
19598
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 8608 times.
9580 if(clk>=0)
19599 8608 enemy::draw(dest);
19600 9580 }
19601
19602
19603 /**********************************/
19604 /********** Misc Code ***********/
19605 /**********************************/
19606
19607 149447 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
19608 {
19609
4/6
✓ Branch 0 taken 116927 times.
✓ Branch 1 taken 32520 times.
✓ Branch 2 taken 116927 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116927 times.
✗ Branch 5 not taken.
149447 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
19610
4/8
✓ Branch 0 taken 149447 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149447 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149447 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 149447 times.
✗ Branch 7 not taken.
149447 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
19611
1/2
✓ Branch 0 taken 149447 times.
✗ Branch 1 not taken.
149447 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19612 149447 }
19613
19614 32619 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
19615 {
19616 // Kludge
19617
4/8
✓ Branch 0 taken 32619 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32619 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 32619 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 32619 times.
✗ Branch 7 not taken.
32619 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
19618 32619 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
19619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32619 times.
32619 delete w;
19620 32619 return ret;
19621 }
19622
19623 3475 void enemy_scored(int32_t index)
19624 {
19625 3475 ((enemy*)guys.spr(index))->scored=true;
19626 3475 }
19627
19628 1201 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy)
19629 {
19630
7/12
✓ Branch 0 taken 1201 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1201 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1201 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1201 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115 times.
✓ Branch 9 taken 1086 times.
✓ Branch 10 taken 1201 times.
✗ Branch 11 not taken.
1201 guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_bit(quest_rules,qr_NOGUYPOOF)?0:clk,mainguy);
19631 1201 guys.add(g);
19632 1201 }
19633
19634 21863 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
19635 {
19636
5/10
✓ Branch 0 taken 21863 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21863 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21863 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21863 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21863 times.
✗ Branch 9 not taken.
21863 item *i = new item(zfix(x), zfix(y - get_bit(quest_rules, qr_NOITEMOFFSET)), zfix(0), id, pickup, 0);
19637 21863 items.add(i);
19638 21863 }
19639
19640 70 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
19641 {
19642
6/12
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 70 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 70 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 70 times.
✗ Branch 11 not taken.
70 item *i = new item((zfix)x,(zfix)y-(get_bit(quest_rules, qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
19643 70 items.add(i);
19644 70 }
19645
19646 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
19647 {
19648 item *i = new item((zfix)x,(zfix)y-(get_bit(quest_rules, qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
19649 items.add(i);
19650 }
19651
19652 56 void kill_em_all()
19653 {
19654
2/2
✓ Branch 0 taken 251 times.
✓ Branch 1 taken 56 times.
307 for(int32_t i=0; i<guys.Count(); i++)
19655 {
19656 251 enemy *e = ((enemy*)guys.spr(i));
19657
19658
3/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
251 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
19659
19660 226 e->kickbucket();
19661 226 }
19662 56 }
19663
19664 bool can_kill_em_all()
19665 {
19666 for(int32_t i=0; i<guys.Count(); i++)
19667 {
19668 enemy *e = ((enemy*)guys.spr(i));
19669
19670 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
19671 if(e->superman) continue;
19672 return true;
19673 }
19674 return false;
19675 }
19676
19677 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
19678 // For Hero's hit detection. Don't count them if they are stunned or are guys.
19679 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
19680 {
19681 for(int32_t i=0; i<guys.Count(); i++)
19682 {
19683 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
19684 {
19685 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_bit(quest_rules, qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
19686 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
19687 {
19688 return i;
19689 }
19690 }
19691 }
19692
19693 return -1;
19694 }
19695
19696 5506517 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
19697 {
19698
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5506517 times.
✓ Branch 2 taken 16218733 times.
✓ Branch 3 taken 5494353 times.
21713086 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
19699 {
19700
2/2
✓ Branch 0 taken 12164 times.
✓ Branch 1 taken 16206569 times.
16218733 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
19701 {
19702 12164 return i;
19703 }
19704 16206569 }
19705
19706 5494353 return -1;
19707 5506517 }
19708
19709 // For Hero's hit detection. Count them if they are dying.
19710 24241 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
19711 {
19712 24241 enemy *e = (enemy*)guys.spr(index);
19713
3/4
✓ Branch 0 taken 24241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13304 times.
✓ Branch 3 taken 10937 times.
24241 if(!e || e->hp > 0)
19714 13304 return -1;
19715
19716 10937 bool d = e->dying;
19717 10937 int32_t hc = e->hclk;
19718 10937 e->dying = false;
19719 10937 e->hclk = 0;
19720 10937 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
19721 10937 e->dying = d;
19722 10937 e->hclk = hc;
19723
19724
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 10856 times.
10937 return hit ? index : -1;
19725 24241 }
19726
19727 5985082 bool hasMainGuy()
19728 {
19729
2/2
✓ Branch 0 taken 7588257 times.
✓ Branch 1 taken 2152890 times.
9741147 for(int32_t i=0; i<guys.Count(); i++)
19730 {
19731
2/2
✓ Branch 0 taken 3832192 times.
✓ Branch 1 taken 3756065 times.
7588257 if(((enemy*)guys.spr(i))->mainguy)
19732 {
19733 3832192 return true;
19734 }
19735 3756065 }
19736
19737 2152890 return false;
19738 5985082 }
19739
19740 49 void EatHero(int32_t index)
19741 {
19742 49 ((eStalfos*)guys.spr(index))->eathero();
19743 49 }
19744
19745 3 void GrabHero(int32_t index)
19746 {
19747 3 ((eWallM*)guys.spr(index))->grabhero();
19748 3 }
19749
19750 292 bool CarryHero()
19751 {
19752
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 for(int32_t i=0; i<guys.Count(); i++)
19753 {
19754
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 355 times.
891 if(((guy*)(guys.spr(i)))->family==eeWALLM)
19755 {
19756
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 63 times.
355 if(((eWallM*)guys.spr(i))->hashero)
19757 {
19758 292 Hero.x=guys.spr(i)->x;
19759 292 Hero.y=guys.spr(i)->y;
19760 292 return ((eWallM*)guys.spr(i))->misc > 0;
19761 }
19762 63 }
19763
19764 // Like Likes currently can't carry Hero.
19765 /*
19766 if(((guy*)(guys.spr(i)))->family==eeLIKE)
19767 {
19768 if(((eLikeLike*)guys.spr(i))->hashero)
19769 {
19770 Hero.x=guys.spr(i)->x;
19771 Hero.y=guys.spr(i)->y;
19772 return (true);
19773 }
19774 }*/
19775 599 }
19776
19777 return false;
19778 292 }
19779
19780 // Move item with guy
19781 void movefairy(zfix &x,zfix &y,int32_t misc)
19782 {
19783 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
19784
19785 if(i!=-1)
19786 {
19787 x = guys.spr(i)->x;
19788 y = guys.spr(i)->y;
19789 }
19790 }
19791
19792 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
19793 void movefairy2(zfix x,zfix y,int32_t misc)
19794 {
19795 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
19796
19797 if(i!=-1)
19798 {
19799 guys.spr(i)->x = x;
19800 guys.spr(i)->y = y;
19801 }
19802 }// Move item with guy
19803
19804 29595 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
19805 {
19806 29595 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
19807
19808
1/2
✓ Branch 0 taken 29595 times.
✗ Branch 1 not taken.
29595 if(fairy)
19809 {
19810 29595 x = fairy->x;
19811 29595 y = fairy->y;
19812 29595 }
19813 29595 }
19814
19815 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
19816 void movefairynew2(zfix x,zfix y, item const &itemfairy)
19817 {
19818 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
19819
19820 if(fairy)
19821 {
19822 fairy->x = x;
19823 fairy->y = y;
19824 }
19825 }
19826
19827 void killfairy(int32_t misc)
19828 {
19829 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
19830 guys.del(i);
19831 }
19832
19833 int32_t getGuyIndex(const int32_t eid)
19834 {
19835 for(word i = 0; i < guys.Count(); i++)
19836 {
19837 if(guys.spr(i)->getUID() == eid)
19838 return i;
19839 }
19840
19841 return -1;
19842 }
19843
19844 void killfairynew(item const &itemfairy)
19845 {
19846 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
19847 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
19848 }
19849
19850 //Should probably change this to return an 'enemy*', null on failure -Em
19851 10334 int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk)
19852 {
19853 10334 return addenemy(x,y,0,id,clk);
19854 }
19855
19856 868 int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID)
19857 {
19858 868 return addchild(x,y,0,id,clk, parent_scriptUID);
19859 }
19860
19861 893 int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID)
19862 {
19863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 if(id <= 0) return 0;
19864
19865 893 int32_t ret = 0;
19866 893 sprite *e=NULL;
19867 893 al_trace("Adding child\n");
19868
19869
5/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 857 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
893 switch(guysbuf[id&0xFFF].family)
19870 {
19871 //Fixme: possible enemy memory leak. (minor)
19872 case eeWALK:
19873
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
16 e = new eStalfos((zfix)x,(zfix)y,id,clk);
19874 16 break;
19875
19876 case eeLEV:
19877 e = new eLeever((zfix)x,(zfix)y,id,clk);
19878 break;
19879
19880 case eeTEK:
19881 e = new eTektite((zfix)x,(zfix)y,id,clk);
19882 break;
19883
19884 case eePEAHAT:
19885 e = new ePeahat((zfix)x,(zfix)y,id,clk);
19886 break;
19887
19888 case eeZORA:
19889 e = new eZora((zfix)x,(zfix)y,id,clk);
19890 break;
19891
19892 case eeGHINI:
19893 e = new eGhini((zfix)x,(zfix)y,id,clk);
19894 break;
19895
19896 case eeKEESE:
19897
3/6
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 857 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 857 times.
✗ Branch 5 not taken.
857 e = new eKeese((zfix)x,(zfix)y,id,clk);
19898 857 break;
19899
19900 case eeWIZZ:
19901
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
19902 15 break;
19903
19904 case eePROJECTILE:
19905 e = new eProjectile((zfix)x,(zfix)y,id,clk);
19906 break;
19907
19908 case eeWALLM:
19909 e = new eWallM((zfix)x,(zfix)y,id,clk);
19910 break;
19911
19912 case eeAQUA:
19913 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
19914 break;
19915
19916 case eeMOLD:
19917 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
19918 break;
19919
19920 case eeMANHAN:
19921
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
19922 1 break;
19923
19924 case eeGLEEOK:
19925 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
19926 break;
19927
19928 case eeGHOMA:
19929 e = new eGohma((zfix)x,(zfix)y,id,clk);
19930 break;
19931
19932 case eeLANM:
19933 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
19934 break;
19935
19936 case eeGANON:
19937 e = new eGanon((zfix)x,(zfix)y,id,clk);
19938 break;
19939
19940 case eeFAIRY:
19941 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
19942 break;
19943
19944 case eeFIRE:
19945 e = new eFire((zfix)x,(zfix)y,id,clk);
19946 break;
19947
19948 case eeOTHER:
19949 e = new eOther((zfix)x,(zfix)y,id,clk);
19950 break;
19951
19952
19953 case eeSCRIPT01:
19954 case eeSCRIPT02:
19955 case eeSCRIPT03:
19956 case eeSCRIPT04:
19957 case eeSCRIPT05:
19958 case eeSCRIPT06:
19959 case eeSCRIPT07:
19960 case eeSCRIPT08:
19961 case eeSCRIPT09:
19962 case eeSCRIPT10:
19963 case eeSCRIPT11:
19964 case eeSCRIPT12:
19965 case eeSCRIPT13:
19966 case eeSCRIPT14:
19967 case eeSCRIPT15:
19968 case eeSCRIPT16:
19969 case eeSCRIPT17:
19970 case eeSCRIPT18:
19971 case eeSCRIPT19:
19972 case eeSCRIPT20:
19973 {
19974 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
19975 {
19976 e = new eScript((zfix)x,(zfix)y,id,clk);
19977 break;
19978 }
19979 else return 0;
19980 }
19981
19982 case eeFFRIENDLY01:
19983 case eeFFRIENDLY02:
19984 case eeFFRIENDLY03:
19985 case eeFFRIENDLY04:
19986 case eeFFRIENDLY05:
19987 case eeFFRIENDLY06:
19988 case eeFFRIENDLY07:
19989 case eeFFRIENDLY08:
19990 case eeFFRIENDLY09:
19991 case eeFFRIENDLY10:
19992 {
19993 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
19994 {
19995 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
19996 }
19997 else return 0;
19998
19999 }
20000
20001 case eeSPINTILE:
20002 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
20003 break;
20004
20005 // and these enemies use the misc10/misc2 value
20006 case eeROCK:
20007 {
20008 switch(guysbuf[id&0xFFF].misc10)
20009 {
20010 case 1:
20011 e = new eBoulder((zfix)x,(zfix)y,id,clk);
20012 break;
20013
20014 case 0:
20015 default:
20016 e = new eRock((zfix)x,(zfix)y,id,clk);
20017 break;
20018 }
20019
20020 break;
20021 }
20022
20023 case eeTRAP:
20024 {
20025 switch(guysbuf[id&0xFFF].misc2)
20026 {
20027 case 1:
20028 e = new eTrap2((zfix)x,(zfix)y,id,clk);
20029 break;
20030
20031 case 0:
20032 default:
20033 e = new eTrap((zfix)x,(zfix)y,id,clk);
20034 break;
20035 }
20036
20037 break;
20038 }
20039
20040 case eeDONGO:
20041 {
20042 switch(guysbuf[id&0xFFF].misc10)
20043 {
20044 case 1:
20045 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
20046 break;
20047
20048 case 0:
20049 default:
20050 e = new eDodongo((zfix)x,(zfix)y,id,clk);
20051 break;
20052 }
20053
20054 break;
20055 }
20056
20057 case eeDIG:
20058 {
20059
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].misc10)
20060 {
20061 case 1:
20062 e = new eLilDig((zfix)x,(zfix)y,id,clk);
20063 break;
20064
20065 4 case 0:
20066 default:
20067
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
20068 4 break;
20069 }
20070
20071 4 break;
20072 }
20073
20074 case eePATRA:
20075 {
20076 switch(guysbuf[id&0xFFF].misc10)
20077 {
20078 case 1:
20079 if (get_bit(quest_rules,qr_HARDCODED_BS_PATRA))
20080 {
20081 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
20082 break;
20083 }
20084 [[fallthrough]];
20085 case 0:
20086 default:
20087 e = new ePatra((zfix)x,(zfix)y,id,clk);
20088 break;
20089 }
20090
20091 break;
20092 }
20093
20094 case eeGUY:
20095 {
20096 switch(guysbuf[id&0xFFF].misc10)
20097 {
20098 case 1:
20099 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20100 break;
20101
20102 case 0:
20103 default:
20104 e = new eNPC((zfix)x,(zfix)y,id,clk);
20105 break;
20106 }
20107
20108 break;
20109 }
20110
20111 case eeNONE:
20112 if(guysbuf[id&0xFFF].misc10 ==1)
20113 {
20114 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20115 break;
20116 break;
20117 }
20118 [[fallthrough]];
20119 default:
20120
20121 return 0;
20122 }
20123
20124 893 ret++; // Made one enemy.
20125
20126
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
893 if(z && canfall(id))
20127 {
20128 e->z = (zfix)z;
20129 }
20130
20131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 ((enemy*)e)->ceiling = (z && canfall(id));
20132 893 ((enemy*)e)->parent_script_UID = parent_scriptUID;
20133 //al_trace("Child Script UID: %d\n",((enemy*)e)->script_UID);
20134 //zprint2("Child Script UID: %d\n",((enemy*)e)->script_UID);
20135 //al_trace("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
20136 //zprint2("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
20137
20138
20139
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 if(!guys.add(e))
20140 {
20141 return 0;
20142 }
20143
20144 // add segments of segmented enemies
20145 893 int32_t c=0;
20146
20147
2/6
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
893 switch(guysbuf[id&0xFFF].family)
20148 {
20149 case eeMOLD:
20150 {
20151 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20152 id &= 0xFFF;
20153
20154 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
20155 {
20156 //christ this is messy -DD
20157 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
20158
20159 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
20160 {
20161 al_trace("Moldorm segment %d could not be created!\n",i+1);
20162
20163 for(int32_t j=0; j<i+1; j++)
20164 guys.del(guys.Count()-1);
20165
20166 return 0;
20167 }
20168
20169 if(i>0)
20170 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20171
20172 ret++;
20173 }
20174
20175 break;
20176 }
20177
20178 case eeLANM:
20179 {
20180 id &= 0xFFF;
20181 int32_t shft = guysbuf[id].misc2;
20182 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20183
20184 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
20185 {
20186 al_trace("Lanmola segment 1 could not be created!\n");
20187 guys.del(guys.Count()-1);
20188 return 0;
20189 }
20190
20191 ret++;
20192
20193 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
20194 {
20195 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
20196 {
20197 al_trace("Lanmola segment %d could not be created!\n",i+1);
20198
20199 for(int32_t j=0; j<i+1; j++)
20200 guys.del(guys.Count()-1);
20201
20202 return 0;
20203 }
20204
20205 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20206 ret++;
20207 }
20208 }
20209 break;
20210
20211 case eeMANHAN:
20212 1 id &= 0xFFF;
20213
20214
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
20215 {
20216
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
20217 {
20218 al_trace("Manhandla head %d could not be created!\n",i+1);
20219
20220 for(int32_t j=0; j<i+1; j++)
20221 {
20222 guys.del(guys.Count()-1);
20223 }
20224
20225 return 0;
20226 }
20227
20228 4 ret++;
20229 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
20230 4 }
20231
20232 1 break;
20233
20234 case eeGLEEOK:
20235 {
20236 id &= 0xFFF;
20237
20238 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
20239 {
20240 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
20241 {
20242 al_trace("Gleeok head %d could not be created!\n",i+1);
20243
20244 for(int32_t j=0; j<i+1; j++)
20245 {
20246 guys.del(guys.Count()-1);
20247 }
20248
20249 return false;
20250 }
20251
20252 c-=guysbuf[id].misc4;
20253 ret++;
20254 }
20255 }
20256 break;
20257
20258
20259 case eePATRA:
20260 {
20261 id &= 0xFFF;
20262 int32_t outeyes = 0;
20263
20264 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
20265 {
20266 if(!((guysbuf[id].misc10&&get_bit(quest_rules,qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
20267 {
20268 al_trace("Patra outer eye %d could not be created!\n",i+1);
20269
20270 for(int32_t j=0; j<i+1; j++)
20271 guys.del(guys.Count()-1);
20272
20273 return 0;
20274 }
20275 else
20276 outeyes++;
20277
20278 ret++;
20279 }
20280
20281 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
20282 {
20283 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
20284 {
20285 al_trace("Patra inner eye %d could not be created!\n",i+1);
20286
20287 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
20288 guys.del(guys.Count()-1);
20289
20290 return 0;
20291 }
20292
20293 ret++;
20294 }
20295
20296 break;
20297 }
20298 }
20299
20300 893 return ret;
20301 893 }
20302
20303 // Returns number of enemies/segments created
20304 39591 int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
20305 {
20306 //zprint2("addenemy id is: %d\n", (id&0xFFF));
20307 39591 int32_t realid = id&0xFFF;
20308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39591 times.
39591 if( realid > MAXGUYS )
20309 {
20310 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "addenemy()");
20311 return 0;
20312 }
20313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39591 times.
39591 if(id <= 0) return 0;
20314
20315 39591 int32_t ret = 0;
20316 39591 sprite *e=NULL;
20317
20318
27/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20964 times.
✓ Branch 4 taken 1454 times.
✓ Branch 5 taken 2264 times.
✓ Branch 6 taken 829 times.
✓ Branch 7 taken 1480 times.
✓ Branch 8 taken 139 times.
✓ Branch 9 taken 4374 times.
✓ Branch 10 taken 1779 times.
✓ Branch 11 taken 2101 times.
✓ Branch 12 taken 461 times.
✓ Branch 13 taken 71 times.
✓ Branch 14 taken 85 times.
✓ Branch 15 taken 57 times.
✓ Branch 16 taken 84 times.
✓ Branch 17 taken 51 times.
✓ Branch 18 taken 111 times.
✓ Branch 19 taken 7 times.
✓ Branch 20 taken 356 times.
✓ Branch 21 taken 79 times.
✓ Branch 22 taken 1278 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 238 times.
✓ Branch 25 taken 795 times.
✓ Branch 26 taken 125 times.
✓ Branch 27 taken 239 times.
✓ Branch 28 taken 53 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 23 times.
39591 switch(guysbuf[id&0xFFF].family)
20319 {
20320 //Fixme: possible enemy memory leak. (minor)
20321 case eeWALK:
20322
3/6
✓ Branch 0 taken 20964 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20964 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20964 times.
✗ Branch 5 not taken.
20964 e = new eStalfos((zfix)x,(zfix)y,id,clk);
20323 20964 break;
20324
20325 case eeLEV:
20326
3/6
✓ Branch 0 taken 1454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1454 times.
✗ Branch 5 not taken.
1454 e = new eLeever((zfix)x,(zfix)y,id,clk);
20327 1454 break;
20328
20329 case eeTEK:
20330
3/6
✓ Branch 0 taken 2264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2264 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2264 times.
✗ Branch 5 not taken.
2264 e = new eTektite((zfix)x,(zfix)y,id,clk);
20331 2264 break;
20332
20333 case eePEAHAT:
20334
3/6
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 829 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 829 times.
✗ Branch 5 not taken.
829 e = new ePeahat((zfix)x,(zfix)y,id,clk);
20335 829 break;
20336
20337 case eeZORA:
20338
3/6
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1480 times.
✗ Branch 5 not taken.
1480 e = new eZora((zfix)x,(zfix)y,id,clk);
20339 1480 break;
20340
20341 case eeGHINI:
20342
3/6
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
139 e = new eGhini((zfix)x,(zfix)y,id,clk);
20343 139 break;
20344
20345 case eeKEESE:
20346
3/6
✓ Branch 0 taken 4374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4374 times.
✗ Branch 5 not taken.
4374 e = new eKeese((zfix)x,(zfix)y,id,clk);
20347 4374 break;
20348
20349 case eeWIZZ:
20350
3/6
✓ Branch 0 taken 1779 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1779 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1779 times.
✗ Branch 5 not taken.
1779 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
20351 1779 break;
20352
20353 case eePROJECTILE:
20354
3/6
✓ Branch 0 taken 2101 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2101 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2101 times.
✗ Branch 5 not taken.
2101 e = new eProjectile((zfix)x,(zfix)y,id,clk);
20355 2101 break;
20356
20357 case eeWALLM:
20358
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eWallM((zfix)x,(zfix)y,id,clk);
20359 461 break;
20360
20361 case eeAQUA:
20362
3/6
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 71 times.
✗ Branch 5 not taken.
71 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
20363 71 break;
20364
20365 case eeMOLD:
20366
6/12
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 85 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 85 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 85 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 85 times.
✓ Branch 10 taken 85 times.
✗ Branch 11 not taken.
85 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
20367 85 break;
20368
20369 case eeMANHAN:
20370
3/6
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57 times.
✗ Branch 5 not taken.
57 e = new eManhandla((zfix)x,(zfix)y,id,clk);
20371 57 break;
20372
20373 case eeGLEEOK:
20374
6/12
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 84 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 84 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 84 times.
✓ Branch 10 taken 84 times.
✗ Branch 11 not taken.
84 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
20375 84 break;
20376
20377 case eeGHOMA:
20378
3/6
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 51 times.
✗ Branch 5 not taken.
51 e = new eGohma((zfix)x,(zfix)y,id,clk);
20379 51 break;
20380
20381 case eeLANM:
20382
6/12
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 111 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 111 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 111 times.
✓ Branch 10 taken 111 times.
✗ Branch 11 not taken.
111 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
20383 111 break;
20384
20385 case eeGANON:
20386
3/6
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
7 e = new eGanon((zfix)x,(zfix)y,id,clk);
20387 7 break;
20388
20389 case eeFAIRY:
20390
3/6
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 356 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 356 times.
✗ Branch 5 not taken.
356 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
20391 356 break;
20392
20393 case eeFIRE:
20394
3/6
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 79 times.
✗ Branch 5 not taken.
79 e = new eFire((zfix)x,(zfix)y,id,clk);
20395 79 break;
20396
20397 case eeOTHER:
20398
3/6
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1278 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1278 times.
✗ Branch 5 not taken.
1278 e = new eOther((zfix)x,(zfix)y,id,clk);
20399 1278 break;
20400
20401
20402 case eeSCRIPT01:
20403 case eeSCRIPT02:
20404 case eeSCRIPT03:
20405 case eeSCRIPT04:
20406 case eeSCRIPT05:
20407 case eeSCRIPT06:
20408 case eeSCRIPT07:
20409 case eeSCRIPT08:
20410 case eeSCRIPT09:
20411 case eeSCRIPT10:
20412 case eeSCRIPT11:
20413 case eeSCRIPT12:
20414 case eeSCRIPT13:
20415 case eeSCRIPT14:
20416 case eeSCRIPT15:
20417 case eeSCRIPT16:
20418 case eeSCRIPT17:
20419 case eeSCRIPT18:
20420 case eeSCRIPT19:
20421 case eeSCRIPT20:
20422 {
20423 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
20424 {
20425 e = new eScript((zfix)x,(zfix)y,id,clk);
20426 break;
20427 }
20428 else return 0;
20429 }
20430
20431 case eeFFRIENDLY01:
20432 case eeFFRIENDLY02:
20433 case eeFFRIENDLY03:
20434 case eeFFRIENDLY04:
20435 case eeFFRIENDLY05:
20436 case eeFFRIENDLY06:
20437 case eeFFRIENDLY07:
20438 case eeFFRIENDLY08:
20439 case eeFFRIENDLY09:
20440 case eeFFRIENDLY10:
20441 {
20442 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
20443 {
20444 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
20445 }
20446 else return 0;
20447
20448 }
20449
20450 case eeSPINTILE:
20451
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
20452 94 break;
20453
20454 // and these enemies use the misc10/misc2 value
20455 case eeROCK:
20456 {
20457
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 208 times.
238 switch(guysbuf[id&0xFFF].misc10)
20458 {
20459 case 1:
20460
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
20461 30 break;
20462
20463 208 case 0:
20464 default:
20465
3/6
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 208 times.
✗ Branch 5 not taken.
208 e = new eRock((zfix)x,(zfix)y,id,clk);
20466 208 break;
20467 }
20468
20469 238 break;
20470 }
20471
20472 case eeTRAP:
20473 {
20474
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✓ Branch 2 taken 655 times.
795 switch(guysbuf[id&0xFFF].misc2)
20475 {
20476 case 1:
20477
3/6
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
140 e = new eTrap2((zfix)x,(zfix)y,id,clk);
20478 140 break;
20479
20480 655 case 0:
20481 default:
20482
3/6
✓ Branch 0 taken 655 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 655 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 655 times.
✗ Branch 5 not taken.
655 e = new eTrap((zfix)x,(zfix)y,id,clk);
20483 655 break;
20484 }
20485
20486 795 break;
20487 }
20488
20489 case eeDONGO:
20490 {
20491
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 123 times.
125 switch(guysbuf[id&0xFFF].misc10)
20492 {
20493 case 1:
20494
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
20495 2 break;
20496
20497 123 case 0:
20498 default:
20499
3/6
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 123 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 123 times.
✗ Branch 5 not taken.
123 e = new eDodongo((zfix)x,(zfix)y,id,clk);
20500 123 break;
20501 }
20502
20503 125 break;
20504 }
20505
20506 case eeDIG:
20507 {
20508
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 45 times.
239 switch(guysbuf[id&0xFFF].misc10)
20509 {
20510 case 1:
20511
3/6
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 194 times.
✗ Branch 5 not taken.
194 e = new eLilDig((zfix)x,(zfix)y,id,clk);
20512 194 break;
20513
20514 45 case 0:
20515 default:
20516
3/6
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
45 e = new eBigDig((zfix)x,(zfix)y,id,clk);
20517 45 break;
20518 }
20519
20520 239 break;
20521 }
20522
20523 case eePATRA:
20524 {
20525
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 3 times.
53 switch(guysbuf[id&0xFFF].misc10)
20526 {
20527 case 1:
20528
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (get_bit(quest_rules,qr_HARDCODED_BS_PATRA))
20529 {
20530
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
20531 3 break;
20532 }
20533 [[fallthrough]];
20534 50 case 0:
20535 default:
20536
3/6
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
50 e = new ePatra((zfix)x,(zfix)y,id,clk);
20537 50 break;
20538 }
20539
20540 53 break;
20541 }
20542
20543 case eeGUY:
20544 {
20545 switch(guysbuf[id&0xFFF].misc10)
20546 {
20547 case 1:
20548 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20549 break;
20550
20551 case 0:
20552 default:
20553 e = new eNPC((zfix)x,(zfix)y,id,clk);
20554 break;
20555 }
20556
20557 break;
20558 }
20559
20560 case eeNONE:
20561
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(guysbuf[id&0xFFF].misc10 ==1)
20562 {
20563
3/6
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
23 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20564 23 break;
20565 break;
20566 }
20567 [[fallthrough]];
20568 default:
20569
20570 return 0;
20571 }
20572
20573 39591 ret++; // Made one enemy.
20574
20575
4/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 39508 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 59 times.
39591 if(z && canfall(id))
20576 {
20577 59 e->z = (zfix)z;
20578 59 }
20579
20580
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 39508 times.
39591 ((enemy*)e)->ceiling = (z && canfall(id));
20581
20582
1/2
✓ Branch 0 taken 39591 times.
✗ Branch 1 not taken.
39591 if(!guys.add(e))
20583 {
20584 return 0;
20585 }
20586
20587 // add segments of segmented enemies
20588 39591 int32_t c=0;
20589
20590
6/6
✓ Branch 0 taken 39201 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 53 times.
39591 switch(guysbuf[id&0xFFF].family)
20591 {
20592 case eeMOLD:
20593 {
20594 85 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20595 85 id &= 0xFFF;
20596
20597
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 570 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 570 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 570 times.
✓ Branch 6 taken 485 times.
✓ Branch 7 taken 85 times.
570 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
20598 {
20599 //christ this is messy -DD
20600 485 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
20601
20602
4/8
✓ Branch 0 taken 485 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 485 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 485 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 485 times.
✗ Branch 7 not taken.
485 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
20603 {
20604 al_trace("Moldorm segment %d could not be created!\n",i+1);
20605
20606 for(int32_t j=0; j<i+1; j++)
20607 guys.del(guys.Count()-1);
20608
20609 return 0;
20610 }
20611
20612
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 400 times.
485 if(i>0)
20613 400 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20614
20615 485 ret++;
20616 485 }
20617
20618 85 break;
20619 }
20620
20621 case eeLANM:
20622 {
20623 111 id &= 0xFFF;
20624 111 int32_t shft = guysbuf[id].misc2;
20625 111 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20626
20627
4/8
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 111 times.
✗ Branch 7 not taken.
111 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
20628 {
20629 al_trace("Lanmola segment 1 could not be created!\n");
20630 guys.del(guys.Count()-1);
20631 return 0;
20632 }
20633
20634 111 ret++;
20635
20636
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 610 times.
✓ Branch 6 taken 499 times.
✓ Branch 7 taken 111 times.
610 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
20637 {
20638
4/8
✓ Branch 0 taken 499 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 499 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 499 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 499 times.
✗ Branch 7 not taken.
499 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
20639 {
20640 al_trace("Lanmola segment %d could not be created!\n",i+1);
20641
20642 for(int32_t j=0; j<i+1; j++)
20643 guys.del(guys.Count()-1);
20644
20645 return 0;
20646 }
20647
20648 499 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20649 499 ret++;
20650 499 }
20651 }
20652 111 break;
20653
20654 case eeMANHAN:
20655 57 id &= 0xFFF;
20656
20657
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 57 times.
317 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
20658 {
20659
4/8
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 260 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 260 times.
✗ Branch 7 not taken.
260 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
20660 {
20661 al_trace("Manhandla head %d could not be created!\n",i+1);
20662
20663 for(int32_t j=0; j<i+1; j++)
20664 {
20665 guys.del(guys.Count()-1);
20666 }
20667
20668 return 0;
20669 }
20670
20671 260 ret++;
20672 260 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
20673 260 }
20674
20675 57 break;
20676
20677 case eeGLEEOK:
20678 {
20679 84 id &= 0xFFF;
20680
20681
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 332 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 332 times.
✓ Branch 6 taken 248 times.
✓ Branch 7 taken 84 times.
332 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
20682 {
20683
4/8
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 248 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 248 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 248 times.
✗ Branch 7 not taken.
248 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
20684 {
20685 al_trace("Gleeok head %d could not be created!\n",i+1);
20686
20687 for(int32_t j=0; j<i+1; j++)
20688 {
20689 guys.del(guys.Count()-1);
20690 }
20691
20692 return false;
20693 }
20694
20695 248 c-=guysbuf[id].misc4;
20696 248 ret++;
20697 248 }
20698 }
20699 84 break;
20700
20701
20702 case eePATRA:
20703 {
20704 53 id &= 0xFFF;
20705 53 int32_t outeyes = 0;
20706
20707
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 471 times.
✓ Branch 2 taken 418 times.
✓ Branch 3 taken 53 times.
471 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
20708 {
20709
10/22
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 400 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 400 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 400 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 400 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 400 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
418 if(!((guysbuf[id].misc10&&get_bit(quest_rules,qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
20710 {
20711 al_trace("Patra outer eye %d could not be created!\n",i+1);
20712
20713 for(int32_t j=0; j<i+1; j++)
20714 guys.del(guys.Count()-1);
20715
20716 return 0;
20717 }
20718 else
20719 418 outeyes++;
20720
20721 418 ret++;
20722 418 }
20723
20724
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 53 times.
141 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
20725 {
20726
4/8
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
88 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
20727 {
20728 al_trace("Patra inner eye %d could not be created!\n",i+1);
20729
20730 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
20731 guys.del(guys.Count()-1);
20732
20733 return 0;
20734 }
20735
20736 88 ret++;
20737 88 }
20738
20739 53 break;
20740 }
20741 }
20742
20743 39591 return ret;
20744 39591 }
20745
20746 711936 bool isjumper(int32_t id)
20747 {
20748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 711936 times.
711936 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20749 {
20750 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isjumper()");
20751 return false;
20752 }
20753
3/3
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 652188 times.
✓ Branch 2 taken 59744 times.
711936 switch(guysbuf[id&0xFFF].family)
20754 {
20755 case eeROCK:
20756 case eeTEK:
20757 4 return true;
20758
20759 case eeWALK:
20760
3/4
✓ Branch 0 taken 59744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 47479 times.
59744 if(guysbuf[id&0xFFF].misc9==e9tVIRE || guysbuf[id&0xFFF].misc9==e9tPOLSVOICE) return true;
20761 47479 }
20762
20763 699667 return false;
20764 711936 }
20765
20766
20767 101260 bool isfixedtogrid(int32_t id)
20768 {
20769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101260 times.
101260 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20770 {
20771 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isfixedtogrid()");
20772 return false;
20773 }
20774
1/2
✓ Branch 0 taken 101260 times.
✗ Branch 1 not taken.
101260 switch(guysbuf[id&0xFFF].family)
20775 {
20776 case eeWALK:
20777 case eeLEV:
20778 case eeZORA:
20779 case eeDONGO:
20780 case eeGANON:
20781 case eeROCK:
20782 case eeGLEEOK:
20783 case eeAQUA:
20784 case eeLANM:
20785 return true;
20786 }
20787
20788 101260 return false;
20789 101260 }
20790
20791 // Can't fall, can have Z value.
20792 25840058 bool isflier(int32_t id)
20793 {
20794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25840058 times.
25840058 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20795 {
20796 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isflier()");
20797 return false;
20798 }
20799
2/2
✓ Branch 0 taken 22973147 times.
✓ Branch 1 taken 2866911 times.
25840058 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
20800 {
20801 case eePEAHAT:
20802 case eeKEESE:
20803 case eePATRA:
20804 case eeFAIRY:
20805 case eeGHINI:
20806
20807 // Could theoretically have their Z set by a script
20808 case eeFIRE:
20809 2866911 return true;
20810 break;
20811 }
20812
20813 22973147 return false;
20814 25840058 }
20815
20816 // Can't have Z position
20817 1169227 bool never_in_air(int32_t id)
20818 {
20819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1169227 times.
1169227 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20820 {
20821 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "never_in_air()");
20822 return false;
20823 }
20824
2/2
✓ Branch 0 taken 1161905 times.
✓ Branch 1 taken 7322 times.
1169227 switch(guysbuf[id&0xFFF].family)
20825 {
20826 case eeMANHAN:
20827 case eeMOLD:
20828 case eeLANM:
20829 case eeGLEEOK:
20830 case eeZORA:
20831 case eeLEV:
20832 case eeAQUA:
20833 case eeROCK:
20834 case eeGANON:
20835 case eeTRAP:
20836 case eePROJECTILE:
20837 case eeSPINTILE:
20838 7322 return true;
20839 }
20840
20841 1161905 return false;
20842 1169227 }
20843
20844 790767 bool canfall(int32_t id)
20845 {
20846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 790767 times.
790767 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20847 {
20848 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "canfall()");
20849 return false;
20850 }
20851
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 790741 times.
✓ Branch 2 taken 26 times.
790767 switch(guysbuf[id&0xFFF].family)
20852 {
20853 case eeGUY:
20854 {
20855
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(id < eOCTO1S)
20856 26 return false;
20857
20858 switch(guysbuf[id&0xFFF].misc10)
20859 {
20860 case 1:
20861 case 2:
20862 return true;
20863
20864 case 0:
20865 case 3:
20866 default:
20867 return false;
20868 }
20869
20870 case eeGHOMA:
20871 case eeDIG:
20872 return false;
20873 }
20874 }
20875
20876
20877
4/4
✓ Branch 0 taken 783419 times.
✓ Branch 1 taken 7322 times.
✓ Branch 2 taken 71483 times.
✓ Branch 3 taken 711936 times.
790741 return !never_in_air(id) && !isflier(id) && !isjumper(id);
20878 790767 }
20879
20880 25554259 bool enemy::enemycanfall(int32_t id, bool checkgrav)
20881 {
20882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25554259 times.
25554259 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20883 {
20884 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "enemycanfall()");
20885 return false;
20886 }
20887 //Z_scripterrlog("canfall family is %d:\n", family);
20888 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & FLAG_OBEYS_GRAV ? "true" : "false");
20889 //if ( family == eeFIRE && id >= eSTART )
20890 //{
20891 // Z_scripterrlog("eeFire\n");
20892 // return moveflags & FLAG_OBEYS_GRAV; //'Other' enemy class, used by scripts. -Z
20893 //}
20894
20895 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
20896
20897
3/3
✓ Branch 0 taken 190752 times.
✓ Branch 1 taken 24612996 times.
✓ Branch 2 taken 750511 times.
25554259 switch(guysbuf[id&0xFFF].family)
20898 {
20899 case eeGUY:
20900 {
20901
1/2
✓ Branch 0 taken 750511 times.
✗ Branch 1 not taken.
750511 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
20902 750511 return false;
20903
20904 switch(guysbuf[id&0xFFF].misc10) //I'm unsure what these specify off-hand. Needs better comments. -Z
20905 {
20906 case 1:
20907 case 2:
20908 return true;
20909
20910 case 0:
20911 case 3:
20912 default:
20913 return false;
20914 }
20915
20916 case eeGHOMA:
20917 case eeDIG:
20918 190752 return false;
20919 }
20920 }
20921
20922
2/2
✓ Branch 0 taken 18410840 times.
✓ Branch 1 taken 6202156 times.
24612996 if(!checkgrav) return true;
20923 18410840 return (moveflags & FLAG_OBEYS_GRAV);
20924
20925 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
20926 // {
20927 // if ( moveflags & FLAG_OBEYS_GRAV ) return true;
20928 // else return false;
20929 // }
20930 // else
20931 // {
20932 // return (moveflags & FLAG_OBEYS_GRAV);
20933 // }
20934 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
20935 25554259 }
20936
20937 578 void addfires()
20938 {
20939
2/2
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 272 times.
578 if(!get_bit(quest_rules,qr_NOGUYFIRES))
20940 {
20941 306 int32_t bs = get_bit(quest_rules,qr_BSZELDA);
20942 306 addguy(bs? 64: 72,64,gFIRE,-17,false);
20943 306 addguy(bs?176:168,64,gFIRE,-18,false);
20944 306 }
20945 578 }
20946
20947 12381 void loadguys()
20948 {
20949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12381 times.
12381 if(loaded_guys)
20950 return;
20951
20952 12381 loaded_guys=true;
20953
20954 12381 byte Guy=0;
20955 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
20956 // Else use mITEM and ipONETIME
20957 12381 int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM;
20958 12381 int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME;
20959
20960 12381 repaircharge=0;
20961 12381 adjustmagic=false;
20962 12381 learnslash=false;
20963
20964
2/2
✓ Branch 0 taken 37149 times.
✓ Branch 1 taken 12381 times.
49530 for(int32_t i=0; i<3; i++)
20965 {
20966 37149 prices[i]=0;
20967 37149 }
20968
20969 12381 hasitem=0;
20970
20971
4/4
✓ Branch 0 taken 657 times.
✓ Branch 1 taken 11724 times.
✓ Branch 2 taken 339 times.
✓ Branch 3 taken 318 times.
12381 if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES)
20972 {
20973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 318 times.
318 if(DMaps[currdmap].flags&dmfCAVES)
20974 {
20975 318 Guy=tmpscr[1].guy;
20976 318 }
20977 318 }
20978 else
20979 {
20980 12063 Guy=tmpscr->guy;
20981
20982
4/4
✓ Branch 0 taken 11726 times.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 7078 times.
✓ Branch 3 taken 4648 times.
12063 if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP))
20983 4648 game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited
20984 }
20985
20986 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
20987
4/4
✓ Branch 0 taken 2557 times.
✓ Branch 1 taken 9824 times.
✓ Branch 2 taken 1964 times.
✓ Branch 3 taken 593 times.
12381 if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES)))
20988 {
20989
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 586 times.
593 if(tmpscr->room==rZELDA)
20990 {
20991 7 addguy(120,72,Guy,-15,true);
20992 7 guys.spr(0)->hxofs=1000;
20993 7 addenemy(128,96,eFIRE,-15);
20994 7 addenemy(112,96,eFIRE,-15);
20995 7 addenemy(96,120,eFIRE,-15);
20996 7 addenemy(144,120,eFIRE,-15);
20997 7 return;
20998 }
20999
21000
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 576 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 2 times.
586 if(Guy!=gFAIRY || !get_bit(quest_rules,qr_NOFAIRYGUYFIRES))
21001 578 addfires();
21002
21003
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 314 times.
590 if(currscr>=128)
21004
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
325 if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN))
21005 11 Guy=0;
21006
21007
3/6
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 485 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
590 switch(tmpscr->room)
21008 {
21009 case rSP_ITEM:
21010 case rGRUMBLE:
21011 case rBOMBS:
21012 case rARROWS:
21013 case rSWINDLE:
21014 case rMUPGRADE:
21015 case rLEARNSLASH:
21016 case rTAKEONE:
21017
8/8
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 53 times.
✓ Branch 5 taken 43 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 33 times.
82 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21018 26 Guy=0;
21019
21020 122 break;
21021
21022 case rREPAIR:
21023 if (get_bit(quest_rules, qr_OLD_DOORREPAIR)) break;
21024 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21025 Guy=0;
21026
21027 break;
21028 case rRP_HC:
21029 if (get_bit(quest_rules, qr_OLD_POTION_OR_HC)) break;
21030 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21031 Guy=0;
21032
21033 break;
21034 case rMONEY:
21035 if (get_bit(quest_rules, qr_OLD_SECRETMONEY)) break;
21036 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21037 Guy=0;
21038
21039 break;
21040
21041 case rTRIFORCE:
21042 {
21043 23 int32_t tc = TriforceCount();
21044
21045
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 11 times.
23 if(get_bit(quest_rules,qr_4TRI))
21046 {
21047
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_bit(quest_rules,qr_3TRI) && tc>=3) || tc>=4)
21048 10 Guy=0;
21049 9 }
21050 else
21051 {
21052
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if((get_bit(quest_rules,qr_3TRI) && tc>=6) || tc>=8)
21053 12 Guy=0;
21054 }
21055 }
21056 21 break;
21057 }
21058
21059
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 531 times.
588 if(Guy)
21060 {
21061
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 521 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
531 if(Guy!=gFAIRY || !get_bit(quest_rules,qr_NOFAIRYGUYFIRES))
21062 521 blockpath=true;
21063
21064
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 228 times.
531 if(currscr<128)
21065 228 sfx(WAV_SCALE);
21066
21067
4/4
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 225 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 303 times.
531 addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true);
21068 531 Hero.Freeze();
21069 531 }
21070 588 }
21071
2/2
✓ Branch 0 taken 11737 times.
✓ Branch 1 taken 51 times.
11788 else if(Guy==gFAIRY) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
21072 {
21073 51 sfx(WAV_SCALE);
21074 51 addguy(120,62,gFAIRY,-14,false);
21075 51 }
21076
21077 12376 loaditem();
21078
21079 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
21080 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
21081
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 12367 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 7 times.
12376 if(tmpscr->room==r10RUPIES && !getmapflag(mf))
21082 {
21083 //setmapflag();
21084
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 7 times.
77 for(int32_t i=0; i<10; i++)
21085 70 additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
21086 7 }
21087 12383 }
21088
21089 12384 void loaditem()
21090 {
21091 12384 byte Item = 0;
21092
21093
2/2
✓ Branch 0 taken 11727 times.
✓ Branch 1 taken 657 times.
12384 if(currscr<128)
21094 {
21095 11727 Item=tmpscr->item;
21096
21097
4/4
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 11162 times.
✓ Branch 2 taken 10591 times.
✓ Branch 3 taken 1136 times.
11727 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21098 {
21099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1136 times.
1136 if(tmpscr->flags8&fSECRETITEM)
21100 hasitem=8;
21101
2/2
✓ Branch 0 taken 567 times.
✓ Branch 1 taken 569 times.
1136 else if(tmpscr->flags&fITEM)
21102 567 hasitem=1;
21103
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 548 times.
569 else if(tmpscr->enemyflags&efCARRYITEM)
21104 21 hasitem=4; // Will be set to 2 by roaming_item
21105 else
21106
2/4
✓ Branch 0 taken 548 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 548 times.
✗ Branch 3 not taken.
1096 items.add(new item((zfix)tmpscr->itemx,
21107
7/14
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 545 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 548 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 548 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 548 times.
✗ Branch 13 not taken.
548 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_bit(quest_rules, qr_NOITEMOFFSET)?0:1),
21108
6/10
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 545 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 545 times.
✗ Branch 9 not taken.
548 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
21109
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 496 times.
548 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
21110 548 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
21111 1136 }
21112 11727 }
21113
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 339 times.
657 else if(!(DMaps[currdmap].flags&dmfCAVES))
21114 {
21115
4/6
✓ Branch 0 taken 339 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 335 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
340 if((!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM
21116
4/4
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 230 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 108 times.
339 && (currscr==128 || !get_bit(quest_rules,qr_ITEMSINPASSAGEWAYS)))
21117 {
21118 109 Item=tmpscr[1].catchall;
21119
21120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(Item)
21121
2/4
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 109 times.
✗ Branch 3 not taken.
218 items.add(new item((zfix)tmpscr->itemx,
21122
4/14
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 109 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 109 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 109 times.
✗ Branch 13 not taken.
109 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_bit(quest_rules, qr_NOITEMOFFSET)?0:1),
21123
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 109 times.
✗ Branch 9 not taken.
109 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
21124 109 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
21125 109 }
21126 339 }
21127 12384 }
21128
21129 502 void never_return(int32_t index)
21130 {
21131
2/2
✓ Branch 0 taken 373 times.
✓ Branch 1 taken 129 times.
502 if(!get_bit(quest_rules,qr_KILLALL))
21132 129 goto doit;
21133
21134
2/2
✓ Branch 0 taken 1257 times.
✓ Branch 1 taken 179 times.
1436 for(int32_t i=0; i<guys.Count(); i++)
21135
4/4
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 787 times.
✓ Branch 2 taken 194 times.
✓ Branch 3 taken 276 times.
1257 if(((((enemy*)guys.spr(i))->d->flags)&guy_neverret) && i!=index)
21136 {
21137 194 goto dontdoit;
21138 179 }
21139
21140 doit:
21141 308 setmapflag(mNEVERRET);
21142 dontdoit:
21143 502 return;
21144 }
21145
21146 27721 bool slowguy(int32_t id)
21147 {
21148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27721 times.
27721 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
21149 {
21150 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "slowguy()");
21151 return false;
21152 }
21153 //return (guysbuf[id].step<100);
21154
2/2
✓ Branch 0 taken 23273 times.
✓ Branch 1 taken 4448 times.
27721 switch(id)
21155 {
21156 case eOCTO1S:
21157 case eOCTO2S:
21158 case eOCTO1F:
21159 case eOCTO2F:
21160 case eLEV1:
21161 case eLEV2:
21162 case eROCK:
21163 case eBOULDER:
21164 4448 return true;
21165 }
21166
21167 23273 return false;
21168 27721 }
21169
21170 31238 bool ok2add(int32_t id)
21171 {
21172
2/4
✓ Branch 0 taken 31238 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31238 times.
31238 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
21173 {
21174 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "oktoadd()");
21175 return false;
21176 }
21177
4/4
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 30871 times.
✓ Branch 2 taken 167 times.
✓ Branch 3 taken 200 times.
31238 if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_neverret))
21178 200 return false;
21179
21180
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30917 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 89 times.
31038 switch(guysbuf[id].family)
21181 {
21182 // I added a special case for shooters because having traps on the same screen
21183 // was preventing them from spawning due to TMPNORET. This means they will
21184 // never stay dead, though, so it may not be the best solution. - Saf
21185 case eePROJECTILE:
21186 32 return true;
21187
21188
21189 case eeDIG:
21190 {
21191
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 44 times.
89 switch(guysbuf[id].misc10)
21192 {
21193 case 1:
21194
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 32 times.
45 if(!get_bit(quest_rules,qr_NOTMPNORET))
21195 13 return !getmapflag(mTMPNORET);
21196
21197 32 return true;
21198
21199 44 case 0:
21200 default:
21201 44 return true;
21202 }
21203 }
21204 case eeGANON:
21205 case eeTRAP:
21206 if ((guysbuf[id].family == eeGANON && !get_bit(quest_rules, qr_CAN_PLACE_GANON))
21207 || (guysbuf[id].family == eeTRAP && !get_bit(quest_rules, qr_CAN_PLACE_TRAPS))) return false;
21208 [[fallthrough]];
21209 default:
21210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30917 times.
30917 if (guysbuf[id].flags2&guy_ignoretmpnr) return true;
21211 30917 break;
21212 }
21213
21214
2/2
✓ Branch 0 taken 8710 times.
✓ Branch 1 taken 22207 times.
30917 if(!get_bit(quest_rules,qr_NOTMPNORET))
21215 22207 return !getmapflag(mTMPNORET);
21216
21217 8710 return true;
21218 31238 }
21219
21220 236400 void activate_fireball_statue(int32_t pos)
21221 {
21222
3/4
✓ Branch 0 taken 99193 times.
✓ Branch 1 taken 137207 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99193 times.
236400 if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0)
21223 {
21224 137207 return;
21225 }
21226
21227 99193 int32_t cx=-1000, cy=-1000;
21228 99193 int32_t x = (pos&15)<<4;
21229 99193 int32_t y = pos&0xF0;
21230
21231 99193 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
21232
21233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99193 times.
99193 if(!isfixedtogrid(statueID))
21234 {
21235
2/2
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 98213 times.
99193 if(ctype==cL_STATUE)
21236 {
21237 980 cx=x+4;
21238 980 cy=y+7;
21239 980 }
21240
2/2
✓ Branch 0 taken 1007 times.
✓ Branch 1 taken 97206 times.
98213 else if(ctype==cR_STATUE)
21241 {
21242 1007 cx=x-8;
21243 1007 cy=y-1;
21244 1007 }
21245
2/2
✓ Branch 0 taken 97126 times.
✓ Branch 1 taken 80 times.
97206 else if(ctype==cC_STATUE)
21246 {
21247 80 cx=x;
21248 80 cy=y;
21249 80 }
21250 99193 }
21251 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
21252 {
21253 cx=x;
21254 cy=y;
21255 }
21256
21257
2/2
✓ Branch 0 taken 97126 times.
✓ Branch 1 taken 2067 times.
99193 if(cx!=-1000) // No point creating it if this is false
21258 {
21259
2/2
✓ Branch 0 taken 6141 times.
✓ Branch 1 taken 2067 times.
8208 for(int32_t j=0; j<guys.Count(); j++)
21260 {
21261
3/4
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 4989 times.
✓ Branch 2 taken 1152 times.
✗ Branch 3 not taken.
6141 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
21262 {
21263 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
21264 return; // No point deleting it. A script might be toying with it in some way.
21265 else
21266 guys.del(j);
21267 }
21268 6141 }
21269
21270 2067 addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
21271 2067 }
21272 236400 }
21273
21274 12301 void activate_fireball_statues()
21275 {
21276
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 11752 times.
12301 if(!(tmpscr->enemyflags&efFIREBALLS))
21277 {
21278 11752 return;
21279 }
21280
21281
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 96624 times.
97173 for(int32_t i=0; i<176; i++)
21282 {
21283 96624 activate_fireball_statue(i);
21284 96624 }
21285 12301 }
21286
21287 12301 void load_default_enemies()
21288 {
21289 12301 wallm_load_clk=frame-80;
21290 12301 int32_t Id=0;
21291
21292
2/2
✓ Branch 0 taken 11337 times.
✓ Branch 1 taken 964 times.
12301 if(tmpscr->enemyflags&efZORA)
21293 {
21294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
964 if(zoraID>=0)
21295 964 addenemy(-16, -16, zoraID, 0);
21296 964 }
21297
21298
2/2
✓ Branch 0 taken 12210 times.
✓ Branch 1 taken 91 times.
12301 if(tmpscr->enemyflags&efTRAP4)
21299 {
21300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91 times.
91 if(cornerTrapID>=0)
21301 {
21302 91 addenemy(32, 32, cornerTrapID, -14);
21303 91 addenemy(208, 32, cornerTrapID, -14);
21304 91 addenemy(32, 128, cornerTrapID, -14);
21305 91 addenemy(208, 128, cornerTrapID, -14);
21306 91 }
21307 91 }
21308
21309
2/2
✓ Branch 0 taken 135311 times.
✓ Branch 1 taken 12301 times.
147612 for(int32_t y=0; y<176; y+=16)
21310 {
21311
2/2
✓ Branch 0 taken 2164976 times.
✓ Branch 1 taken 135311 times.
2300287 for(int32_t x=0; x<256; x+=16)
21312 {
21313 2164976 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
21314 2164976 int32_t cflag = MAPFLAG(x, y);
21315 2164976 int32_t cflag_i = MAPCOMBOFLAG(x, y);
21316
21317
4/6
✓ Branch 0 taken 2164976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2164918 times.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2164918 times.
2164976 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
21318 {
21319
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 48 times.
58 if(trapLOSHorizontalID>=0)
21320 48 addenemy(x, y, trapLOSHorizontalID, -14);
21321 58 }
21322
4/6
✓ Branch 0 taken 2164918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2164894 times.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2164894 times.
2164918 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
21323 {
21324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(trapLOSVerticalID>=0)
21325 24 addenemy(x, y, trapLOSVerticalID, -14);
21326 24 }
21327
4/6
✓ Branch 0 taken 2164894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2164755 times.
✓ Branch 3 taken 139 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2164755 times.
2164894 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
21328 {
21329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if(trapLOS4WayID>=0)
21330 {
21331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if(addenemy(x, y, trapLOS4WayID, -14))
21332 139 guys.spr(guys.Count()-1)->dummy_int[1]=2;
21333 139 }
21334 139 }
21335
21336
4/6
✓ Branch 0 taken 2164755 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2164695 times.
✓ Branch 3 taken 60 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2164695 times.
2164755 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
21337 {
21338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(trapConstantHorizontalID>=0)
21339 60 addenemy(x, y, trapConstantHorizontalID, -14);
21340 60 }
21341
4/6
✓ Branch 0 taken 2164695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2164615 times.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2164615 times.
2164695 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
21342 {
21343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(trapConstantVerticalID>=0)
21344 80 addenemy(x, y, trapConstantVerticalID, -14);
21345 80 }
21346
21347
1/2
✓ Branch 0 taken 2164976 times.
✗ Branch 1 not taken.
2164976 if(ctype==cSPINTILE1)
21348 {
21349 // Awaken spinning tile
21350 awaken_spinning_tile(tmpscr,COMBOPOS(x,y));
21351 }
21352 2164976 }
21353 135311 }
21354
21355
2/2
✓ Branch 0 taken 12259 times.
✓ Branch 1 taken 42 times.
12301 if(tmpscr->enemyflags&efTRAP2)
21356 {
21357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(centerTrapID>=-1)
21358 {
21359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(addenemy(64, 80, centerTrapID, -14))
21360 42 guys.spr(guys.Count()-1)->dummy_int[1]=1;
21361
21362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(addenemy(176, 80, centerTrapID, -14))
21363 42 guys.spr(guys.Count()-1)->dummy_int[1]=1;
21364 42 }
21365 42 }
21366
21367
2/2
✓ Branch 0 taken 12240 times.
✓ Branch 1 taken 61 times.
12301 if(tmpscr->enemyflags&efROCKS)
21368 {
21369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(rockID>=0)
21370 {
21371 61 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
21372 61 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
21373 61 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
21374 61 }
21375 61 }
21376
21377 12301 activate_fireball_statues();
21378 12301 }
21379
21380 15342995 void update_slope_combopos(int32_t lyr, int32_t pos)
21381 {
21382
2/4
✓ Branch 0 taken 15342995 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15342995 times.
15342995 if(unsigned(lyr) > 6 || unsigned(pos) > 175) return;
21383 15342995 mapscr* s = FFCore.tempScreens[lyr];
21384 15342995 newcombo const& cmb = combobuf[s->data[pos]];
21385
21386 15342995 auto id = (176*lyr)+pos;
21387 15342995 auto it = slopes.find(id);
21388
21389 15342995 bool wasSlope = it!=slopes.end();
21390 15342995 bool isSlope = cmb.type == cSLOPE;
21391
21392
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15342995 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15342995 if(isSlope && !wasSlope)
21393 {
21394 slopes.try_emplace(id, &(s->data[pos]), nullptr, id, pos);
21395 }
21396
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15342995 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15342995 else if(wasSlope && !isSlope)
21397 {
21398 slopes.erase(it);
21399 }
21400 15342995 }
21401 12391 void update_slope_comboposes()
21402 {
21403
2/2
✓ Branch 0 taken 86737 times.
✓ Branch 1 taken 12391 times.
99128 for(auto lyr = 0; lyr < 7; ++lyr)
21404 {
21405
2/2
✓ Branch 0 taken 15265712 times.
✓ Branch 1 taken 86737 times.
15352449 for(auto pos = 0; pos < 176; ++pos)
21406 15265712 update_slope_combopos(lyr,pos);
21407 86737 }
21408 12391 }
21409
21410 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
21411 // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L
21412 139776 void screen_combo_modify_preroutine(mapscr *s, int32_t pos)
21413 {
21414 139776 delete_fireball_shooter(s, pos);
21415 139776 }
21416
21417 //Placeholder in case we need it.
21418 void screen_ffc_modify_preroutine(word index)
21419 {
21420 return;
21421 }
21422
21423 // Everything that must be done after we change a screen's combo to another combo. -L
21424 139776 void screen_combo_modify_postroutine(mapscr *s, int32_t pos)
21425 {
21426 139776 s->valid |= mVALID;
21427 139776 activate_fireball_statue(pos);
21428
21429
2/2
✓ Branch 0 taken 139682 times.
✓ Branch 1 taken 94 times.
139776 if(combobuf[s->data[pos]].type==cSPINTILE1)
21430 {
21431 // Awaken spinning tile
21432 94 awaken_spinning_tile(s,pos);
21433 94 }
21434 139776 int32_t lyr = -1;
21435
2/2
✓ Branch 0 taken 88080 times.
✓ Branch 1 taken 51696 times.
139776 if(s == tmpscr) lyr = 0;
21436
2/2
✓ Branch 0 taken 62493 times.
✓ Branch 1 taken 469200 times.
531693 else for(size_t q = 0; q < 6; ++q)
21437 {
21438
2/2
✓ Branch 0 taken 25587 times.
✓ Branch 1 taken 443613 times.
469200 if(s == tmpscr2+q)
21439 {
21440 25587 lyr = q+1;
21441 25587 break;
21442 }
21443 443613 }
21444
2/2
✓ Branch 0 taken 62493 times.
✓ Branch 1 taken 77283 times.
139776 if(lyr > -1)
21445 77283 update_slope_combopos(lyr,pos);
21446 139776 }
21447
21448 2422199 void screen_ffc_modify_postroutine(word index)
21449 {
21450 2422199 ffcdata& ff = tmpscr->ffcs[index];
21451 2422199 newcombo const& cmb = combobuf[ff.getData()];
21452
21453 2422199 auto id = (176*7)+int32_t(index);
21454 2422199 auto it = slopes.find(id);
21455
21456 2422199 bool wasSlope = it!=slopes.end();
21457
1/2
✓ Branch 0 taken 2422199 times.
✗ Branch 1 not taken.
2422199 bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffCHANGER);
21458
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2422199 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2422199 if(isSlope && !wasSlope)
21459 {
21460 slopes.try_emplace(id, nullptr, &ff, id);
21461 }
21462
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2422199 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2422199 else if(wasSlope && !isSlope)
21463 {
21464 slopes.erase(it);
21465 }
21466
21467 2422199 tmpscr->ffcCountMarkDirty();
21468 2422199 }
21469
21470 void screen_combo_modify_pre(int32_t cid)
21471 {
21472 for(auto lyr = 0; lyr < 7; ++lyr)
21473 {
21474 mapscr* t = FFCore.tempScreens[lyr];
21475 for(int32_t i = 0; i < 176; i++)
21476 {
21477 if(t->data[i] == cid)
21478 {
21479 screen_combo_modify_preroutine(t,i);
21480 }
21481 }
21482 }
21483 }
21484 void screen_combo_modify_post(int32_t cid)
21485 {
21486 for(auto lyr = 0; lyr < 7; ++lyr)
21487 {
21488 mapscr* t = FFCore.tempScreens[lyr];
21489 for(int32_t i = 0; i < 176; i++)
21490 {
21491 if(t->data[i] == cid)
21492 {
21493 screen_combo_modify_postroutine(t,i);
21494 }
21495 }
21496 }
21497 for(word ind = 0; ind < MAXFFCS; ++ind)
21498 {
21499 if(tmpscr->ffcs[ind].getData() == cid)
21500 screen_ffc_modify_postroutine(ind);
21501 }
21502 }
21503
21504 94 void awaken_spinning_tile(mapscr *s, int32_t pos)
21505 {
21506
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames));
21507 94 }
21508
21509
21510 // It stands for next_side_pos
21511 9881 void nsp(bool random)
21512 // moves sle_x and sle_y to the next position
21513 {
21514
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 6620 times.
9881 if(random)
21515 {
21516
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
21517 {
21518 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
21519 1634 sle_y = (zc_oldrand()%10)*16;
21520 1634 }
21521 else
21522 {
21523 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
21524 1627 sle_x = (zc_oldrand()%15)*16;
21525 }
21526
21527 3261 return;
21528 }
21529
21530
2/2
✓ Branch 0 taken 5006 times.
✓ Branch 1 taken 1614 times.
6620 if(sle_x==0)
21531 {
21532
2/2
✓ Branch 0 taken 1470 times.
✓ Branch 1 taken 144 times.
1614 if(sle_y<160)
21533 1470 sle_y+=16;
21534 else
21535 144 sle_x+=16;
21536 1614 }
21537
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 2914 times.
5006 else if(sle_y==160)
21538 {
21539
2/2
✓ Branch 0 taken 1957 times.
✓ Branch 1 taken 135 times.
2092 if(sle_x<240)
21540 1957 sle_x+=16;
21541 else
21542 135 sle_y-=16;
21543 2092 }
21544
2/2
✓ Branch 0 taken 1268 times.
✓ Branch 1 taken 1646 times.
2914 else if(sle_x==240)
21545 {
21546
2/2
✓ Branch 0 taken 1147 times.
✓ Branch 1 taken 121 times.
1268 if(sle_y>0)
21547 1147 sle_y-=16;
21548 else
21549 121 sle_x-=16;
21550 1268 }
21551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1646 times.
1646 else if(sle_y==0)
21552 {
21553
1/2
✓ Branch 0 taken 1646 times.
✗ Branch 1 not taken.
1646 if(sle_x>0)
21554 1646 sle_x-=16;
21555 else
21556 sle_y+=16;
21557 1646 }
21558 9881 }
21559
21560 1880 int32_t next_side_pos(bool random)
21561 // moves sle_x and sle_y to the next available position
21562 // returns the direction the enemy should face
21563 {
21564 bool blocked;
21565 1880 int32_t c=0;
21566
21567 1880 do
21568 {
21569
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 9756 times.
9881 nsp(c>35 ? false : random);
21570
3/4
✓ Branch 0 taken 1879 times.
✓ Branch 1 taken 8002 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1879 times.
11760 blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) ||
21571
1/2
✓ Branch 0 taken 1879 times.
✗ Branch 1 not taken.
1879 (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies ||
21572
2/4
✓ Branch 0 taken 1879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1879 times.
✗ Branch 3 not taken.
1879 MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY ||
21573
2/4
✓ Branch 0 taken 1879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1879 times.
1879 MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY ||
21574 1879 iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true));
21575
21576
2/2
✓ Branch 0 taken 9880 times.
✓ Branch 1 taken 1 times.
9881 if(++c>50)
21577 1 return -1;
21578
2/2
✓ Branch 0 taken 8001 times.
✓ Branch 1 taken 1879 times.
9880 }
21579 9880 while(blocked);
21580
21581 1879 int32_t dir=0;
21582
21583
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 567 times.
1879 if(sle_x==0) dir=right;
21584
21585
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 473 times.
1879 if(sle_y==0) dir=down;
21586
21587
2/2
✓ Branch 0 taken 1337 times.
✓ Branch 1 taken 542 times.
1879 if(sle_x==240) dir=left;
21588
21589
1/2
✓ Branch 0 taken 1879 times.
✗ Branch 1 not taken.
1879 if(sle_y==168) dir=up;
21590
21591 1879 return dir;
21592 1880 }
21593
21594 bool can_side_load(int32_t id)
21595 {
21596 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
21597 {
21598 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "can_side_load()");
21599 return false;
21600 }
21601 switch(guysbuf[id].family) //id&0x0FFF)
21602 {
21603 //case eTEK1:
21604 //case eTEK2:
21605 //case eTEK3:
21606 //case eLEV1:
21607 //case eLEV2:
21608 //case eLEV3:
21609 //case eRAQUAM:
21610 //case eLAQUAM:
21611 //case eDODONGO:
21612 //case eMANHAN:
21613 //case eGLEEOK1:
21614 //case eGLEEOK2:
21615 //case eGLEEOK3:
21616 //case eGLEEOK4:
21617 //case eDIG1:
21618 //case eDIG3:
21619 //case eGOHMA1:
21620 //case eGOHMA2:
21621 //case eCENT1:
21622 //case eCENT2:
21623 //case ePATRA1:
21624 //case ePATRA2:
21625 //case eGANON:
21626 //case eMANHAN2:
21627 //case eCEILINGM: later
21628 //case eFLOORM: later
21629 //case ePATRABS:
21630 //case ePATRAL2:
21631 //case ePATRAL3:
21632 //case eGLEEOK1F:
21633 //case eGLEEOK2F:
21634 //case eGLEEOK3F:
21635 //case eGLEEOK4F:
21636 //case eDODONGOBS:
21637 //case eDODONGOF:
21638 //case eGOHMA3:
21639 //case eGOHMA4:
21640 //case eSHOOTMAGIC:
21641 //case eSHOOTROCK:
21642 //case eSHOOTSPEAR:
21643 //case eSHOOTSWORD:
21644 //case eSHOOTFLAME:
21645 //case eSHOOTFLAME2:
21646 //case eSHOOTFBALL:
21647 case eeTEK:
21648 case eeLEV:
21649 case eeAQUA:
21650 case eeDONGO:
21651 case eeMANHAN:
21652 case eeGLEEOK:
21653 case eeDIG:
21654 case eeGHOMA:
21655 case eeLANM:
21656 case eePATRA:
21657 case eeGANON:
21658 case eePROJECTILE:
21659 return false;
21660 break;
21661 }
21662
21663 return true;
21664 }
21665
21666 static bool script_sle = false;
21667 static int32_t sle_pattern = 0;
21668 void script_side_load_enemies()
21669 {
21670 if(script_sle || sle_clk) return;
21671 sle_cnt = 0;
21672 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21673 ++sle_cnt;
21674 script_sle = true;
21675 sle_pattern = tmpscr->pattern;
21676 sle_clk = 0;
21677 }
21678
21679 41772 void side_load_enemies()
21680 {
21681
3/4
✓ Branch 0 taken 41772 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41204 times.
✓ Branch 3 taken 568 times.
41772 if(!script_sle && sle_clk==0)
21682 {
21683 568 sle_pattern = tmpscr->pattern;
21684 568 sle_cnt = 0;
21685 568 int32_t guycnt = 0;
21686 568 int16_t s = (currmap<<7)+currscr;
21687 568 bool beenhere=false;
21688 568 bool reload=true;
21689 568 bool unbeatablereload = true;
21690
21691 568 load_default_enemies();
21692
21693
2/2
✓ Branch 0 taken 3408 times.
✓ Branch 1 taken 568 times.
3976 for(int32_t i=0; i<6; i++)
21694
2/2
✓ Branch 0 taken 3236 times.
✓ Branch 1 taken 172 times.
3580 if(visited[i]==s)
21695 172 beenhere=true;
21696
21697
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 396 times.
568 if(!beenhere)
21698 {
21699 396 visited[vhead]=s;
21700 396 vhead = (vhead+1)%6;
21701 396 }
21702
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 39 times.
172 else if(game->guys[s]==0)
21703 {
21704 39 sle_cnt=0;
21705 39 reload=false;
21706 39 }
21707
21708
2/2
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 179 times.
568 if(reload)
21709 {
21710 179 sle_cnt = game->guys[s];
21711
21712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179 times.
179 if((get_bit(quest_rules, qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
21713
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 176 times.
179 || sle_cnt==0)
21714 {
21715
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 975 times.
✓ Branch 2 taken 801 times.
✓ Branch 3 taken 176 times.
977 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21716 801 ++sle_cnt;
21717 176 }
21718
3/4
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 133 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 396 times.
529 if (!beenhere && get_bit(quest_rules, qr_UNBEATABLES_DONT_KEEP_DEAD))
21719 {
21720 for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++)
21721 {
21722 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
21723 {
21724 unbeatablereload = false;
21725 }
21726 }
21727 if (unbeatablereload)
21728 {
21729 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21730 {
21731 ++sle_cnt;
21732 }
21733 }
21734 }
21735 529 }
21736
21737
4/4
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 350 times.
✓ Branch 2 taken 350 times.
✓ Branch 3 taken 218 times.
918 if((get_bit(quest_rules,qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN))
21738 {
21739 700 sle_cnt = 0;
21740
21741
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
700 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21742 ++sle_cnt;
21743 }
21744
21745
2/2
✓ Branch 0 taken 1839 times.
✓ Branch 1 taken 218 times.
2057 for(int32_t i=0; i<sle_cnt; i++)
21746 1839 ++guycnt;
21747
21748 218 game->guys[s] = guycnt;
21749 218 }
21750
21751
2/2
✓ Branch 0 taken 39542 times.
✓ Branch 1 taken 1880 times.
41422 if((++sle_clk+8)%24 == 0)
21752 {
21753 1880 int32_t dir = next_side_pos(sle_pattern==pSIDESR);
21754
21755
4/4
✓ Branch 0 taken 1879 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 188 times.
✓ Branch 3 taken 1691 times.
1880 if(dir==-1 || tooclose(sle_x,sle_y,32))
21756 {
21757 189 return;
21758 }
21759
21760 1691 int32_t enemy_slot=guys.Count();
21761
21762
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1691 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1691 times.
1691 while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1]))
21763 sle_cnt--;
21764
21765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1691 times.
1691 if(sle_cnt > 0)
21766 {
21767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1691 times.
1691 if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0))
21768 {
21769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1691 times.
1691 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
21770 {
21771 1691 guys.spr(enemy_slot)->dir = dir;
21772 1691 }
21773 1691 }
21774 1691 }
21775 1691 }
21776
21777
2/2
✓ Branch 0 taken 40730 times.
✓ Branch 1 taken 503 times.
41233 if(sle_cnt<=0)
21778 {
21779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 503 times.
503 if(script_sle)
21780 script_sle = false;
21781 503 else loaded_enemies=true;
21782 503 sle_clk = 0;
21783 503 }
21784 41422 }
21785
21786 1096499 bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t)
21787 {
21788
21789
4/4
✓ Branch 0 taken 997751 times.
✓ Branch 1 taken 98748 times.
✓ Branch 2 taken 98748 times.
✓ Branch 3 taken 1096499 times.
1096499 if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
21790 {
21791 //zprint2("is_starting_pos(), tmpscr->enemy[i] is: %d\n", tmpscr->enemy[i]);
21792 197496 return false; //never 0, never OoB.
21793 }
21794 // No corner enemies
21795
6/6
✓ Branch 0 taken 937405 times.
✓ Branch 1 taken 159094 times.
✓ Branch 2 taken 38402 times.
✓ Branch 3 taken 975807 times.
✓ Branch 4 taken 109720 times.
✓ Branch 5 taken 87776 times.
1096499 if((x==0 || x==240) && (y==0 || y==160))
21796
21797 197496 return false;
21798
21799 //Is a no spawn combo...
21800
3/4
✓ Branch 0 taken 975803 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 975803 times.
975807 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
21801 4 return false;
21802
21803 // No enemies in dungeon walls
21804
10/10
✓ Branch 0 taken 630183 times.
✓ Branch 1 taken 345620 times.
✓ Branch 2 taken 558663 times.
✓ Branch 3 taken 71520 times.
✓ Branch 4 taken 487143 times.
✓ Branch 5 taken 71520 times.
✓ Branch 6 taken 401319 times.
✓ Branch 7 taken 85824 times.
✓ Branch 8 taken 85824 times.
✓ Branch 9 taken 315495 times.
975803 if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144))
21805 314688 return false;
21806
21807 // Too close
21808
4/4
✓ Branch 0 taken 68624 times.
✓ Branch 1 taken 592491 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 68620 times.
661115 if(tooclose(x,y,40) && t<11)
21809 68620 return false;
21810
21811 // Can't fly onto it?
21812
4/4
✓ Branch 0 taken 114180 times.
✓ Branch 1 taken 478315 times.
✓ Branch 2 taken 34001 times.
✓ Branch 3 taken 16220 times.
642716 if(isflier(tmpscr->enemy[i])&&
21813
2/2
✓ Branch 0 taken 114020 times.
✓ Branch 1 taken 160 times.
114180 (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])||
21814
2/2
✓ Branch 0 taken 50221 times.
✓ Branch 1 taken 63799 times.
114020 (_walkflag(x,y+8,2)&&!get_bit(quest_rules,qr_WALLFLIERS))))
21815 16380 return false;
21816
21817 // Can't jump onto it?
21818 if
21819 (
21820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84077 times.
660192 guysbuf[tmpscr->enemy[i]].family==eeTEK
21821
21822
2/2
✓ Branch 0 taken 84077 times.
✓ Branch 1 taken 492038 times.
576115 &&
21823 (
21824
1/2
✓ Branch 0 taken 84077 times.
✗ Branch 1 not taken.
84077 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
21825
1/2
✓ Branch 0 taken 84077 times.
✗ Branch 1 not taken.
84077 COMBOTYPE(x+8,y+8)==cNOENEMY||
21826
1/2
✓ Branch 0 taken 84077 times.
✗ Branch 1 not taken.
84077 ispitfall(x+8,y+8)||
21827
1/2
✓ Branch 0 taken 84077 times.
✗ Branch 1 not taken.
84077 MAPFLAG(x+8,y+8)==mfNOENEMY||
21828 84077 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
21829 )
21830 )
21831 {
21832 return false;
21833 }
21834
21835 // Other off-limit combos
21836
6/6
✓ Branch 0 taken 478315 times.
✓ Branch 1 taken 97800 times.
✓ Branch 2 taken 394238 times.
✓ Branch 3 taken 84077 times.
✓ Branch 4 taken 230030 times.
✓ Branch 5 taken 164208 times.
970353 if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK &&
21837
2/2
✓ Branch 0 taken 233302 times.
✓ Branch 1 taken 160936 times.
394238 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) &&
21838 394238 guysbuf[tmpscr->enemy[i]].family!=eeZORA)
21839 164208 return false;
21840
21841 // Don't ever generate enemies on these combos!
21842
3/4
✓ Branch 0 taken 411608 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 411608 times.
411907 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
21843 299 return false;
21844
21845 //BS Dodongos need at least 2 spaces.
21846
4/4
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 410660 times.
✓ Branch 2 taken 946 times.
✓ Branch 3 taken 2 times.
411608 if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].misc10==1))
21847 {
21848
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
21849 ((x>224)||_walkflag(x+16,y+8, 2))&&
21850 ((y<16) ||_walkflag(x, y-8, 2))&&
21851 ((y>144)||_walkflag(x, y+24,2)))
21852 {
21853 return false;
21854 }
21855 2 }
21856
21857 411608 return true;
21858 997751 }
21859
21860 58514 bool is_ceiling_pattern(int32_t i)
21861 {
21862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58514 times.
58514 return (i==pCEILING || i==pCEILINGR);
21863 }
21864
21865 5486 int32_t placeenemy(int32_t i)
21866 {
21867 5486 std::map<int32_t, int32_t> freeposcache;
21868 5486 int32_t frees = 0;
21869
21870
2/2
✓ Branch 0 taken 60346 times.
✓ Branch 1 taken 5486 times.
65832 for(int32_t y=0; y<176; y+=16)
21871 {
21872
2/2
✓ Branch 0 taken 965536 times.
✓ Branch 1 taken 60346 times.
1025882 for(int32_t x=0; x<256; x+=16)
21873 {
21874
3/4
✓ Branch 0 taken 965536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 389372 times.
✓ Branch 3 taken 576164 times.
965536 if(is_starting_pos(i,x,y,0))
21875 {
21876
1/2
✓ Branch 0 taken 389372 times.
✗ Branch 1 not taken.
389372 freeposcache[frees++] = (y&0xF0)+(x>>4);
21877 389372 }
21878 965536 }
21879 60346 }
21880
21881
2/2
✓ Branch 0 taken 5485 times.
✓ Branch 1 taken 1 times.
5486 if(frees > 0)
21882
2/4
✓ Branch 0 taken 5485 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5485 times.
✗ Branch 3 not taken.
5485 return freeposcache[zc_oldrand()%frees];
21883
21884 1 return -1;
21885 5486 }
21886
21887 29548 void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt)
21888 {
21889 29548 bool placed=false;
21890 29548 int32_t t=-1;
21891
21892 // First: enemy combo flags
21893
2/2
✓ Branch 0 taken 315978 times.
✓ Branch 1 taken 27722 times.
343700 for(int32_t sy=0; sy<176; sy+=16)
21894 {
21895
2/2
✓ Branch 0 taken 5042341 times.
✓ Branch 1 taken 314152 times.
5356493 for(int32_t sx=0; sx<256; sx+=16)
21896 {
21897 5042341 int32_t cflag = MAPFLAG(sx, sy);
21898 5042341 int32_t cflag_i = MAPCOMBOFLAG(sx, sy);
21899
21900
2/4
✓ Branch 0 taken 5042341 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5042341 times.
✗ Branch 3 not taken.
5042341 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
21901 {
21902 if(!ok2add(tmpscr->enemy[i]))
21903 {
21904 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
21905 }
21906 else
21907 {
21908 addenemy(sx,
21909 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
21910 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
21911
21912 ++guycnt;
21913
21914 placed=true;
21915 goto placed_enemy;
21916 }
21917 }
21918
21919
4/4
✓ Branch 0 taken 5040515 times.
✓ Branch 1 taken 1826 times.
✓ Branch 2 taken 5040515 times.
✓ Branch 3 taken 1826 times.
5042341 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
21920 {
21921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1826 times.
1826 if(!ok2add(tmpscr->enemy[i]))
21922 {
21923 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
21924 }
21925 else
21926 {
21927 3652 addenemy(sx,
21928
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1826 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1826 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
21929
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1826 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1826 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
21930
21931 1826 ++guycnt;
21932
21933 1826 placed=true;
21934 1826 goto placed_enemy;
21935 }
21936 }
21937 5040515 }
21938 314152 }
21939
21940 // Next: enemy pattern
21941
6/8
✓ Branch 0 taken 4892 times.
✓ Branch 1 taken 22830 times.
✓ Branch 2 taken 22264 times.
✓ Branch 3 taken 5458 times.
✓ Branch 4 taken 22264 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 22264 times.
27722 if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS)))
21942 {
21943 22264 do
21944 {
21945
21946 // NES positions
21947 32243 pos%=9;
21948 32243 x=stx[loadside][pos];
21949 32243 y=sty[loadside][pos];
21950 32243 ++pos;
21951 32243 ++t;
21952
2/2
✓ Branch 0 taken 9979 times.
✓ Branch 1 taken 22264 times.
54507 }
21953
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 32215 times.
32243 while((t< 20) && !is_starting_pos(i,x,y,t));
21954 22264 }
21955
21956
4/4
✓ Branch 0 taken 22264 times.
✓ Branch 1 taken 5458 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 22236 times.
27722 if(t<0 || t >= 20) // above enemy pattern failed
21957 {
21958 // Final chance: find a random position anywhere onscreen
21959 5486 int32_t randpos = placeenemy(i);
21960
21961
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5485 times.
5486 if(randpos>-1)
21962 {
21963 5485 x=(randpos&15)<<4;
21964 5485 y= randpos&0xF0;
21965 5485 }
21966 else // All opportunities failed - abort
21967 {
21968 1 return;
21969 }
21970 5485 }
21971
21972 {
21973 27721 int32_t c=0;
21974 27721 c=clk;
21975
21976
2/2
✓ Branch 0 taken 4448 times.
✓ Branch 1 taken 23273 times.
27721 if(!slowguy(tmpscr->enemy[i]))
21977 23273 ++fastguys;
21978
2/2
✓ Branch 0 taken 655 times.
✓ Branch 1 taken 3793 times.
4448 else if(fastguys>0)
21979 655 c=-15*(i-fastguys+2);
21980 else
21981 3793 c=-15*(i+1);
21982
21983
4/6
✓ Branch 0 taken 1661 times.
✓ Branch 1 taken 26060 times.
✓ Branch 2 taken 1661 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1661 times.
27721 if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
21984 {
21985 // Special case for blue leevers
21986
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1659 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
1661 if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].misc1==1)
21987 2 c=-15*(i+1);
21988 else
21989 1659 c=-15;
21990 1661 }
21991
21992
2/2
✓ Branch 0 taken 27431 times.
✓ Branch 1 taken 290 times.
27721 if(!ok2add(tmpscr->enemy[i]))
21993 {
21994
4/6
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 243 times.
✓ Branch 2 taken 47 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
290 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
21995 290 }
21996 else
21997 {
21998
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27431 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
27431 if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
21999 {
22000
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 27348 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
54862 addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
22001
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 27348 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
27431 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c);
22002
22003 27431 ++guycnt;
22004 27431 }
22005 }
22006
22007 27721 placed=true;
22008 27721 } // if(t < 20)
22009
22010 placed_enemy:
22011
22012 // I don't like this, but it seems to work...
22013 static bool foundCarrier;
22014
22015
2/2
✓ Branch 0 taken 22492 times.
✓ Branch 1 taken 7055 times.
29547 if(i==0)
22016 7055 foundCarrier=false;
22017
22018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29547 times.
29547 if(placed)
22019 {
22020
4/4
✓ Branch 0 taken 7055 times.
✓ Branch 1 taken 22492 times.
✓ Branch 2 taken 6916 times.
✓ Branch 3 taken 139 times.
29547 if(i==0 && tmpscr->enemyflags&efLEADER)
22021 {
22022 139 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
22023
22024
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 7 times.
139 if(index!=-1)
22025 {
22026 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
22027
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
132 if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_bit(quest_rules, qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF);
22028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(index!=-1)
22029 {
22030 132 ((enemy*)guys.spr(index))->leader = true;
22031 132 }
22032 132 }
22033 139 }
22034
22035
4/4
✓ Branch 0 taken 29486 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 29465 times.
✓ Branch 3 taken 21 times.
29547 if(!foundCarrier && hasitem&(4|2))
22036 {
22037 21 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
22038
22039
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesntcount)==0)
22040 {
22041 21 ((enemy*)guys.spr(index))->itemguy = true;
22042 21 foundCarrier=true;
22043 21 }
22044 21 }
22045 29547 }
22046 29548 }
22047
22048 bool scriptloadenemies()
22049 {
22050 loaded_enemies = true;
22051 if(script_sle || sle_clk) return false;
22052 if(tmpscr->pattern==pNOSPAWN) return false;
22053
22054 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
22055 {
22056 script_side_load_enemies();
22057 return true;
22058 }
22059
22060 int32_t pos=zc_oldrand()%9;
22061 int32_t clk=-15,x=0,y=0,fastguys=0;
22062 int32_t i=0,guycnt=0;
22063 int32_t loadcnt = 10;
22064
22065 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
22066 {
22067 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
22068
22069 --clk;
22070 }
22071 return true;
22072 }
22073
22074 5956339 void loadenemies()
22075 {
22076
3/4
✓ Branch 0 taken 5956339 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41204 times.
✓ Branch 3 taken 5915135 times.
5956339 if(script_sle || sle_clk)
22077 {
22078 41204 side_load_enemies();
22079 41204 return;
22080 }
22081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5915135 times.
5915135 if(tmpscr->pattern==pNOSPAWN) return;
22082
2/2
✓ Branch 0 taken 5902803 times.
✓ Branch 1 taken 12332 times.
5915135 if(loaded_enemies)
22083 5902803 return;
22084
22085 // check if it's the dungeon boss and it has been beaten before
22086
4/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 12213 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 31 times.
12332 if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS)
22087 {
22088 31 loaded_enemies = true;
22089 31 return;
22090 }
22091
22092
4/4
✓ Branch 0 taken 11974 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 11733 times.
12301 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
22093 {
22094 568 side_load_enemies();
22095 568 return;
22096 }
22097
22098 11733 loaded_enemies=true;
22099
22100 // do enemies that are always loaded
22101 11733 load_default_enemies();
22102
22103 // dungeon basements
22104
22105 static byte dngn_enemy_x[4] = {32,96,144,208};
22106
22107
2/2
✓ Branch 0 taken 657 times.
✓ Branch 1 taken 11076 times.
11733 if(currscr>=128)
22108 {
22109
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 339 times.
657 if(DMaps[currdmap].flags&dmfCAVES) return;
22110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
339 if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES )
22111 {
22112 for(int32_t i=0; i<10; i++)
22113 {
22114 if ( tmpscr->enemy[i] )
22115 {
22116 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i);
22117 }
22118 }
22119 }
22120 else
22121 {
22122
2/2
✓ Branch 0 taken 1356 times.
✓ Branch 1 taken 339 times.
1695 for(int32_t i=0; i<4; i++)
22123
2/2
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 392 times.
1356 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i);
22124 }
22125 339 return;
22126 }
22127
22128 // check if it's been long enough to reload all enemies
22129
22130 11076 int32_t loadcnt = 10;
22131 11076 int16_t s = (currmap<<7)+currscr;
22132 11076 bool beenhere = false;
22133 11076 bool reload = true;
22134 11076 bool unbeatablereload = true;
22135
22136
2/2
✓ Branch 0 taken 66456 times.
✓ Branch 1 taken 11076 times.
77532 for(int32_t i=0; i<6; i++)
22137
2/2
✓ Branch 0 taken 63143 times.
✓ Branch 1 taken 3313 times.
69769 if(visited[i]==s)
22138 3313 beenhere = true;
22139
22140
2/2
✓ Branch 0 taken 3313 times.
✓ Branch 1 taken 7763 times.
11076 if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
22141 {
22142 7763 visited[vhead]=s; //If not, it adds it to the array,
22143 7763 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
22144 7763 }
22145
2/2
✓ Branch 0 taken 1443 times.
✓ Branch 1 taken 1870 times.
3313 else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0,
22146 {
22147 1870 loadcnt = 0; //It will tell it not to load any enemies,
22148 1870 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
22149 1870 }
22150
22151
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 9206 times.
11076 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
22152 {
22153 9206 loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
22154
22155
2/4
✓ Branch 0 taken 3033 times.
✓ Branch 1 taken 6173 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9206 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
22156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3033 times.
3033 (get_bit(quest_rules, qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
22157 6173 loadcnt = 10; //That means all enemies need to be respawned.
22158
3/4
✓ Branch 0 taken 7763 times.
✓ Branch 1 taken 1443 times.
✓ Branch 2 taken 7763 times.
✗ Branch 3 not taken.
9206 if (!beenhere && get_bit(quest_rules, qr_UNBEATABLES_DONT_KEEP_DEAD))
22159 {
22160 for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++)
22161 {
22162 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
22163 {
22164 unbeatablereload = false;
22165 }
22166 }
22167 if (unbeatablereload)
22168 {
22169 loadcnt = 10;
22170 }
22171 }
22172 9206 }
22173
22174
3/4
✓ Branch 0 taken 11076 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 11026 times.
11076 if((get_bit(quest_rules,qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
22175 50 loadcnt = 10; //All enemies also need to be respawned.
22176
22177 11076 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
22178 11076 int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
22179 11076 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
22180
22181
4/4
✓ Branch 0 taken 5071 times.
✓ Branch 1 taken 35553 times.
✓ Branch 2 taken 29548 times.
✓ Branch 3 taken 11076 times.
40624 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
22182 {
22183 29548 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
22184
22185 29548 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
22186 29548 }
22187
22188 11076 game->guys[s] = guycnt;
22189 //} //if(true)
22190 5956339 }
22191 112 void moneysign()
22192 {
22193 112 additem(48,108,iRupy,ipDUMMY);
22194 // textout(scrollbuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1);
22195 112 set_clip_state(pricesdisplaybuf, 0);
22196 112 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
22197 112 }
22198
22199 895 void putprices(bool sign)
22200 {
22201
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 889 times.
895 if(fadeclk > 0) return;
22202 // refresh what's under the prices
22203 // for(int32_t i=5; i<12; i++)
22204 // putcombo(scrollbuf,i<<4,112,tmpscr->data[112+i],tmpscr->cpage);
22205
22206 889 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
22207 889 int32_t step=32;
22208 889 int32_t x=80;
22209
22210
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 751 times.
889 if(prices[2]==0)
22211 {
22212 751 step<<=1;
22213
22214
2/2
✓ Branch 0 taken 731 times.
✓ Branch 1 taken 20 times.
751 if(prices[1]==0)
22215 {
22216 731 x=112;
22217 731 }
22218 751 }
22219
22220
2/2
✓ Branch 0 taken 889 times.
✓ Branch 1 taken 2667 times.
3556 for(int32_t i=0; i<3; i++)
22221 {
22222 // Kind of stupid, but it works: 100000 is used to indicate that an item
22223 // has a price of zero rather than there being no item.
22224 // 100000 isn't a valid price, so this doesn't cause problems.
22225
3/4
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 2189 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 478 times.
2667 if(prices[i]!=0 && prices[i]<100000)
22226 {
22227 char buf[8];
22228 478 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
22229
22230 478 int32_t l=(int32_t)strlen(buf);
22231 478 set_clip_state(pricesdisplaybuf, 0);
22232
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 457 times.
478 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
22233 478 }
22234
22235 2667 x+=step;
22236 2667 }
22237 895 }
22238
22239 // Setting up special rooms
22240 // Also called when the Letter is used successfully.
22241 542 void setupscreen()
22242 {
22243 542 boughtsomething=false;
22244 542 int32_t t=currscr<128?0:1;
22245 542 word str=tmpscr[t].str;
22246
22247 // Prices are already set to 0 in dowarp()
22248
13/15
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 35 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 10 times.
✓ Branch 10 taken 25 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 8 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 13 times.
542 switch(tmpscr[t].room)
22249 {
22250 case rSP_ITEM: // special item
22251 94 additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
22252 94 break;
22253
22254 case rINFO: // pay for info
22255 {
22256 8 int32_t count = 0;
22257 8 int32_t base = 88;
22258 8 int32_t step = 5;
22259
22260 8 moneysign();
22261
22262
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 24 times.
32 for(int32_t i=0; i<3; i++)
22263 {
22264
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(QMisc.info[tmpscr[t].catchall].str[i])
22265 {
22266 24 ++count;
22267 24 }
22268 else
22269 break;
22270 24 }
22271
22272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(count)
22273 {
22274
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(count==1)
22275 {
22276 base = 88+32;
22277 }
22278
22279
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(count==2)
22280 {
22281 step = 6;
22282 }
22283
22284
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 8 times.
32 for(int32_t i=0; i < count; i++)
22285 {
22286 24 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
22287 24 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
22288 24 prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]);
22289
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(prices[i]==0)
22290 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
22291 24 int32_t itemid = current_item_id(itype_wealthmedal);
22292
22293
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24 if(itemid>=0 && prices[i]!=100000)
22294 {
22295 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22296 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
22297 else
22298 prices[i]-=itemsbuf[itemid].misc1;
22299 prices[i]=vbound(prices[i], -99999, 0);
22300 if(prices[i]==0)
22301 prices[i]=100000;
22302 }
22303
22304
2/6
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
22305 prices[i]=-1;
22306 24 }
22307 8 }
22308
22309 8 break;
22310 }
22311
22312 case rMONEY: // secret money
22313 35 additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
22314 35 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22315 35 break;
22316
22317 case rGAMBLE: // gambling
22318 5 prices[0]=prices[1]=prices[2]=-10;
22319 5 moneysign();
22320 5 additem(88,89,iRupy,ipMONEY+ipDUMMY);
22321 5 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22322 5 additem(120,89,iRupy,ipMONEY+ipDUMMY);
22323 5 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
22324 5 additem(152,89,iRupy,ipMONEY+ipDUMMY);
22325 5 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
22326 5 break;
22327
22328 case rREPAIR: // door repair
22329
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
22330 // }
22331 12 repaircharge=tmpscr[t].catchall;
22332 12 break;
22333
22334 case rMUPGRADE: // upgrade magic
22335 1 adjustmagic=true;
22336 1 break;
22337
22338 case rLEARNSLASH: // learn slash attack
22339 1 learnslash=true;
22340 1 break;
22341
22342 case rRP_HC: // heart container or red potion
22343 10 additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
22344 10 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22345 10 additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
22346 10 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
22347 10 break;
22348
22349 case rP_SHOP: // potion shop
22350
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 if(current_item(itype_letter)<i_letter_used)
22351 {
22352 5 str=0;
22353 5 break;
22354 }
22355
22356 [[fallthrough]];
22357 case rTAKEONE: // take one
22358 case rSHOP: // shop
22359 {
22360 100 int32_t count = 0;
22361 100 int32_t base = 88;
22362 100 int32_t step = 5;
22363
22364
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 99 times.
100 if(tmpscr[t].room != rTAKEONE)
22365 99 moneysign();
22366
22367 //count and align the stuff
22368
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 296 times.
385 for(int32_t i=0; i<3; ++i)
22369 {
22370
2/2
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 11 times.
296 if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0)
22371 {
22372 285 ++count;
22373 285 }
22374 else
22375 {
22376 11 break;
22377 }
22378 285 }
22379
22380
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 4 times.
100 if(count==1)
22381 {
22382 4 base = 88+32;
22383 4 }
22384
22385
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 7 times.
100 if(count==2)
22386 {
22387 7 step = 6;
22388 7 }
22389
22390
2/2
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 100 times.
385 for(int32_t i=0; i<count; i++)
22391 {
22392 285 additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK));
22393 285 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
22394
22395
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 283 times.
285 if(tmpscr[t].room != rTAKEONE)
22396 {
22397 283 prices[i] = QMisc.shop[tmpscr[t].catchall].price[i];
22398
1/2
✓ Branch 0 taken 283 times.
✗ Branch 1 not taken.
283 if(prices[i]==0)
22399 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
22400 283 int32_t itemid = current_item_id(itype_wealthmedal);
22401
22402
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 283 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
283 if(itemid>=0 && prices[i]!=100000)
22403 {
22404 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22405 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
22406 else
22407 prices[i]+=itemsbuf[itemid].misc1;
22408 prices[i]=vbound(prices[i], 0, 99999);
22409 if(prices[i]==0)
22410 prices[i]=100000;
22411 }
22412
22413
2/4
✓ Branch 0 taken 283 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 283 times.
✗ Branch 3 not taken.
283 if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1)
22414 prices[i]=1;
22415 283 }
22416 285 }
22417
22418 100 break;
22419 }
22420 case rBOTTLESHOP: // bottle shop
22421 {
22422 int32_t count = 0;
22423 int32_t base = 88;
22424 int32_t step = 5;
22425
22426 moneysign();
22427 bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall];
22428 //count and align the stuff
22429 for(int32_t i=0; i<3; ++i)
22430 {
22431 if(bst.fill[count] != 0)
22432 {
22433 ++count;
22434 }
22435 else
22436 {
22437 break;
22438 }
22439 }
22440
22441 if(count==1)
22442 {
22443 base = 88+32;
22444 }
22445
22446 if(count==2)
22447 {
22448 step = 6;
22449 }
22450
22451 for(int32_t i=0; i<count; i++)
22452 {
22453 adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
22454 //{ Setup dummy item
22455 item* curItem = ((item*)items.spr(items.Count()-1));
22456 curItem->PriceIndex = i;
22457 newcombo const& cmb = combobuf[bst.comb[i]];
22458 curItem->o_tile = cmb.o_tile;
22459 curItem->o_cset = bst.cset[i];
22460 curItem->cs = curItem->o_cset;
22461 curItem->tile = cmb.o_tile;
22462 curItem->o_speed = cmb.speed;
22463 curItem->o_delay = 0;
22464 curItem->frames = cmb.frames;
22465 curItem->flip = cmb.flip;
22466 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
22467 curItem->pstring = 0;
22468 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
22469 curItem->flash = false;
22470 curItem->twohand = false;
22471 curItem->anim = true;
22472 curItem->hxsz=1;
22473 curItem->hyofs=4;
22474 curItem->hysz=12;
22475 curItem->script=0;
22476 curItem->txsz=1;
22477 curItem->tysz=1;
22478 //}
22479
22480 prices[i] = bst.price[i];
22481 if(prices[i]==0)
22482 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
22483 int32_t itemid = current_item_id(itype_wealthmedal);
22484
22485 if(itemid>=0 && prices[i]!=100000)
22486 {
22487 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22488 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
22489 else
22490 prices[i]+=itemsbuf[itemid].misc1;
22491 prices[i]=vbound(prices[i], 0, 99999);
22492 if(prices[i]==0)
22493 prices[i]=100000;
22494 }
22495
22496 if((bst.price[i])>1 && prices[i]<1)
22497 prices[i]=1;
22498 }
22499
22500 break;
22501 }
22502
22503 case rBOMBS: // more bombs
22504 8 additem(120,89,iRupy,ipDUMMY+ipMONEY);
22505 8 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22506 8 prices[0]=-tmpscr[t].catchall;
22507 8 break;
22508
22509 case rARROWS: // more arrows
22510 additem(120,89,iRupy,ipDUMMY+ipMONEY);
22511 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22512 prices[0]=-tmpscr[t].catchall;
22513 break;
22514
22515 case rSWINDLE: // leave heart container or money
22516 13 additem(88,89,iHeartC,ipDUMMY+ipMONEY);
22517 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22518 13 prices[0]=-1;
22519 13 additem(152,89,iRupy,ipDUMMY+ipMONEY);
22520 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
22521 13 prices[1]=-tmpscr[t].catchall;
22522 13 break;
22523
22524 }
22525
22526
3/4
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 534 times.
542 if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS)
22527 {
22528 8 int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0);
22529 8 int32_t itemid = current_item_id(itype_wealthmedal);
22530
22531
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(itemid >= 0)
22532 {
22533 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22534 prices[i]*=(itemsbuf[itemid].misc1/100.0);
22535 else
22536 prices[i]+=itemsbuf[itemid].misc1;
22537 }
22538
22539
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(tmpscr[t].catchall>1 && prices[i]>-1)
22540 prices[i]=-1;
22541 8 }
22542
22543 542 putprices(false);
22544
22545
2/2
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 26 times.
542 if(str)
22546 {
22547 516 donewmsg(str);
22548 516 }
22549 else
22550 {
22551 26 Hero.unfreeze();
22552 }
22553 542 }
22554
22555 // Increments msgptr and returns the control code argument pointed at.
22556 630 word grab_next_argument()
22557 {
22558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 630 times.
630 if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0;
22559 630 byte val=MsgStrings[msgstr].s[++msgptr]-1;
22560 630 word ret=val;
22561
22562 // If an argument is succeeded by 255, then it's a three-byte argument -
22563 // between 254 and 65535 (or whatever the maximum actually is)
22564
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size())
22565
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255)
22566 {
22567 val=MsgStrings[msgstr].s[msgptr+2];
22568 word next=val;
22569 ret += 254*next;
22570 msgptr+=2;
22571 }
22572
22573 630 return ret;
22574 630 }
22575
22576 enum
22577 {
22578 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
22579 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
22580
22581 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
22582
22583 MNU_DATA_MAX
22584 };
22585 struct menu_choice
22586 {
22587 int32_t x, y;
22588 int32_t pos;
22589 int32_t upos, dpos, lpos, rpos;
22590 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
22591 {}
22592 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
22593 int32_t dpos, int32_t lpos, int32_t rpos)
22594 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
22595 {}
22596 };
22597 static int32_t msg_menu_data[MNU_DATA_MAX];
22598 static bool do_run_menu = false;
22599 bool do_end_str = false;
22600 static bool wait_advance = false;
22601 30 static std::map<int32_t, menu_choice> menu_options;
22602 14162 void clr_msg_data()
22603 {
22604 14162 do_end_str = false;
22605 14162 wait_advance = false;
22606 14162 do_run_menu = false;
22607 14162 menu_options.clear();
22608 14162 memset(msg_menu_data, 0, sizeof(msg_menu_data));
22609 14162 }
22610
22611 static bool doing_name_insert = false;
22612 static char namebuf[9] = {0};
22613 static char* nameptr = NULL;
22614 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
22615 bool runMenuCursor()
22616 {
22617 clear_bitmap(msg_menu_bmp_buf);
22618 if(!menu_options.size())
22619 {
22620 msg_menu_data[MNU_CHOSEN] = 0;
22621 return true; //end menu
22622 }
22623 int32_t pos = msg_menu_data[MNU_CHOSEN];
22624 //If the cursor is at an invalid pos, find the first pos >= 0...
22625 if(menu_options.find(pos) == menu_options.end())
22626 {
22627 pos = 0;
22628 while(menu_options.find(pos) == menu_options.end())
22629 ++pos;
22630 }
22631 menu_choice* ch = &menu_options[pos];
22632
22633 bool pressed = true;
22634 if(rUp()) pos = ch->upos;
22635 else if(rDown()) pos = ch->dpos;
22636 else if(rLeft()) pos = ch->lpos;
22637 else if(rRight()) pos = ch->rpos;
22638 else pressed = false;
22639
22640 if(pressed)
22641 msg_menu_data[MNU_TIMER] = 1;
22642
22643 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 5);
22644 bool held = false;
22645 if(hold_input)
22646 {
22647 held = true;
22648 if(Up()) pos = ch->upos;
22649 else if(Down()) pos = ch->dpos;
22650 else if(Left()) pos = ch->lpos;
22651 else if(Right()) pos = ch->rpos;
22652 else held = false;
22653 }
22654 //If the cursor is at an invalid pos, find the first pos >= 0...
22655 if(menu_options.find(pos) == menu_options.end())
22656 {
22657 pos = 0;
22658 while(menu_options.find(pos) == menu_options.end())
22659 ++pos;
22660 }
22661 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
22662 sfx(MsgStrings[msgstr].sfx);
22663
22664 ch = &menu_options[pos];
22665 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
22666 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
22667 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
22668 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
22669
22670 msg_menu_data[MNU_CHOSEN] = pos;
22671
22672 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
22673 {
22674 rAbtn(); //Eat
22675 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
22676 }
22677
22678 bool ret = (pressed || held) ? false : rAbtn();
22679 //Eat inputs
22680 rUp(); rDown(); rLeft(); rRight(); rAbtn();
22681
22682 if(ret)
22683 menu_options.clear();
22684
22685 return ret;
22686 //false if pos changed this frame; no confirming while moving the cursor!
22687 }
22688
22689 127884 bool bottom_margin_clip()
22690 {
22691 128184 return !get_bit(quest_rules, qr_OLD_STRING_EDITOR_MARGINS)
22692
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 127584 times.
127884 && cursor_y >= (msg_h + (get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
22693 }
22694
22695 void update_msgstr();
22696 55010 bool parsemsgcode()
22697 {
22698
2/2
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 54525 times.
55010 if(msgptr>=MsgStrings[msgstr].s.size()) return false;
22699 54525 byte c = byte(MsgStrings[msgstr].s[msgptr]-1);
22700
4/38
✗ Branch 0 not taken.
✓ Branch 1 taken 54195 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 301 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
54525 switch(c)
22701 {
22702 case MSGC_NEWLINE:
22703 {
22704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
22705 1 ssc_tile_hei = ssc_tile_hei_buf;
22706 1 ssc_tile_hei_buf = -1;
22707 1 cursor_y += thei + MsgStrings[msgstr].vspace;
22708 1 cursor_x=msg_margins[left];
22709 1 return true;
22710 }
22711
22712 case MSGC_COLOUR:
22713 {
22714 301 int32_t cset = (grab_next_argument());
22715 301 msgcolour = CSET(cset)+(grab_next_argument());
22716 301 return true;
22717 }
22718
22719 case MSGC_SHDCOLOR:
22720 {
22721 int32_t cset = (grab_next_argument());
22722 msg_shdcol = CSET(cset)+(grab_next_argument());
22723 return true;
22724 }
22725 case MSGC_SHDTYPE:
22726 {
22727 msg_shdtype = grab_next_argument();
22728 return true;
22729 }
22730
22731 case MSGC_SPEED:
22732 {
22733 28 msgspeed=grab_next_argument();
22734 28 return true;
22735 }
22736
22737 case MSGC_CTRUP:
22738 {
22739 int32_t a1 = grab_next_argument();
22740 int32_t a2 = grab_next_argument();
22741 game->change_counter(a2, a1);
22742 return true;
22743 }
22744
22745 case MSGC_CTRDN:
22746 {
22747 int32_t a1 = grab_next_argument();
22748 int32_t a2 = grab_next_argument();
22749 game->change_counter(-a2, a1);
22750 return true;
22751 }
22752
22753 case MSGC_CTRSET:
22754 {
22755 int32_t a1 = grab_next_argument();
22756 int32_t a2 = grab_next_argument();
22757 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
22758 return true;
22759 }
22760
22761 case MSGC_CTRUPPC:
22762 case MSGC_CTRDNPC:
22763 case MSGC_CTRSETPC:
22764 {
22765 int32_t code = MsgStrings[msgstr].s[msgptr]-1;
22766 int32_t counter = grab_next_argument();
22767 int32_t amount = grab_next_argument();
22768 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
22769
22770 if(code==MSGC_CTRDNPC)
22771 amount*=-1;
22772
22773 if(code==MSGC_CTRSETPC)
22774 game->set_counter(amount, counter);
22775 else
22776 game->change_counter(amount, counter);
22777
22778 return true;
22779 }
22780
22781 case MSGC_GIVEITEM:
22782 {
22783 int32_t itemID = grab_next_argument();
22784
22785 getitem(itemID, true);
22786 if ( !item_doscript[itemID] && (((unsigned)itemID) < 256) )
22787 {
22788 itemScriptData[itemID].Clear();
22789 memset(item_stack[itemID], 0xFFFF, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
22790 if ( (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) ) item_doscript[itemID] = 1;
22791 }
22792 return true;
22793 }
22794
22795
22796 case MSGC_WARP:
22797 {
22798 int32_t dmap = grab_next_argument();
22799 int32_t scrn = grab_next_argument();
22800 int32_t dx = grab_next_argument();
22801 int32_t dy = grab_next_argument();
22802 int32_t wfx = grab_next_argument();
22803 int32_t sfx = grab_next_argument();
22804 if(dx >= MAX_SCC_ARG) dx = -1;
22805 if(dy >= MAX_SCC_ARG) dy = -1;
22806 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, warpFlagDONTKILLMUSIC, 0);
22807 return true;
22808 }
22809
22810 case MSGC_SETSCREEND:
22811 {
22812 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
22813 int32_t screen = grab_next_argument();
22814 int32_t reg = grab_next_argument();
22815 int32_t val = grab_next_argument();
22816 FFCore.set_screen_d(screen + dmap, reg, val);
22817 return true;
22818 }
22819 case MSGC_TAKEITEM:
22820 {
22821 int32_t itemID = grab_next_argument();
22822 if ( item_doscript[itemID] )
22823 {
22824 item_doscript[itemID] = 4; //Val of 4 means 'clear stack and quit'
22825 }
22826 takeitem(itemID);
22827 if ( game->forced_bwpn == itemID )
22828 {
22829 game->forced_bwpn = -1;
22830 } //not else if! -Z
22831 if ( game->forced_awpn == itemID )
22832 {
22833 game->forced_awpn = -1;
22834 }
22835 if ( game->forced_xwpn == itemID )
22836 {
22837 game->forced_xwpn = -1;
22838 } //not else if! -Z
22839 if ( game->forced_ywpn == itemID )
22840 {
22841 game->forced_ywpn = -1;
22842 }
22843 verifyBothWeapons();
22844 return true;
22845 }
22846
22847 case MSGC_SFX:
22848 {
22849 sfx((int32_t)grab_next_argument(),128);
22850 return true;
22851 }
22852
22853 case MSGC_MIDI:
22854 {
22855 int32_t music = (int32_t)(grab_next_argument());
22856
22857 if(music==0)
22858 music_stop();
22859 else
22860 jukebox(music+(ZC_MIDI_COUNT-1));
22861
22862 return true;
22863 }
22864
22865 case MSGC_NAME:
22866 {
22867 doing_name_insert = true;
22868 sprintf(namebuf, "%s", game->get_name());
22869 nameptr = namebuf;
22870 return true;
22871 }
22872
22873 case MSGC_FONT:
22874 {
22875 int fontid = grab_next_argument();
22876 int oh = text_height(msgfont);
22877 msgfont = get_zc_font(fontid);
22878 int nh = text_height(msgfont);
22879 int mh = std::max(oh,nh);
22880 if(mh > ssc_tile_hei_buf)
22881 ssc_tile_hei_buf = mh;
22882 return true;
22883 }
22884 case MSGC_RUN_FRZ_GENSCR:
22885 {
22886 word scr_id = grab_next_argument();
22887 bool force_redraw = grab_next_argument()!=0;
22888 if(force_redraw)
22889 {
22890 update_msgstr();
22891 draw_screen(tmpscr);
22892 }
22893 FFCore.runGenericFrozenEngine(scr_id);
22894 return true;
22895 }
22896 case MSGC_DRAWTILE:
22897 {
22898 int32_t tl = grab_next_argument();
22899 int32_t cs = grab_next_argument();
22900 int32_t t_wid = grab_next_argument();
22901 int32_t t_hei = grab_next_argument();
22902 int32_t fl = grab_next_argument();
22903
22904 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
22905 {
22906 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
22907 ssc_tile_hei = ssc_tile_hei_buf;
22908 ssc_tile_hei_buf = -1;
22909 cursor_y += thei + MsgStrings[msgstr].vspace;
22910 if(bottom_margin_clip()) return true;
22911 cursor_x=msg_margins[left];
22912 }
22913
22914 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
22915 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
22916 cursor_x += MsgStrings[msgstr].hspace + t_wid;
22917 return true;
22918 }
22919
22920 case MSGC_GOTOIFRAND:
22921 {
22922 int32_t odds = (int32_t)(grab_next_argument());
22923
22924 if(!odds || !(zc_oldrand()%odds))
22925 goto switched;
22926
22927 (void)grab_next_argument();
22928 return true;
22929 }
22930
22931 case MSGC_GOTOIFGLOBAL:
22932 {
22933 int32_t arg = (int32_t)grab_next_argument();
22934 int32_t d = zc_min(7,arg);
22935 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
22936 arg = (int32_t)grab_next_argument();
22937
22938 if(game->screen_d[s][d] >= arg)
22939 goto switched;
22940
22941 (void)grab_next_argument();
22942 return true;
22943 }
22944
22945 case MSGC_CHANGEPORTRAIT:
22946 {
22947 return true; //not implemented
22948 }
22949
22950 case MSGC_GOTOIFCREEND:
22951 {
22952 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
22953 int32_t screen = grab_next_argument();
22954 int32_t reg = grab_next_argument();
22955 int32_t val = grab_next_argument();
22956 //int32_t nxtstr = grab_next_argument();
22957 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
22958 {
22959 goto switched;
22960 }
22961 (void)grab_next_argument();
22962 return true;
22963 }
22964
22965 case MSGC_GOTOIF:
22966 {
22967 int32_t it = (int32_t)grab_next_argument();
22968
22969 if(unsigned(it)<MAXITEMS && game->item[it])
22970 goto switched;
22971
22972 (void)grab_next_argument();
22973 return true;
22974 }
22975
22976 case MSGC_GOTOIFCTR:
22977 {
22978 if(game->get_counter(grab_next_argument())>=grab_next_argument())
22979 goto switched;
22980
22981 (void)grab_next_argument();
22982 return true;
22983 }
22984
22985 case MSGC_GOTOIFCTRPC:
22986 {
22987 int32_t counter = grab_next_argument();
22988 int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter));
22989
22990 if(game->get_counter(counter)>=amount)
22991 goto switched;
22992
22993 (void)grab_next_argument();
22994 return true;
22995 }
22996
22997 case MSGC_GOTOIFTRICOUNT:
22998 {
22999 if(TriforceCount() >= (int32_t)(grab_next_argument()))
23000 goto switched;
23001
23002 (void)grab_next_argument();
23003 return true;
23004 }
23005
23006 case MSGC_GOTOIFTRI:
23007 {
23008 int32_t lev = (int32_t)(grab_next_argument());
23009
23010 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
23011 goto switched;
23012
23013 (void)grab_next_argument();
23014 return true;
23015 }
23016
23017 case MSGC_SETUPMENU:
23018 {
23019 msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument();
23020 msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument();
23021 msg_menu_data[MNU_CURSOR_WID] = grab_next_argument();
23022 msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument();
23023 msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument();
23024 return true;
23025 }
23026
23027 case MSGC_MENUCHOICE:
23028 {
23029 int32_t pos = grab_next_argument();
23030 int32_t upos = grab_next_argument();
23031 int32_t dpos = grab_next_argument();
23032 int32_t lpos = grab_next_argument();
23033 int32_t rpos = grab_next_argument();
23034 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
23035 {
23036 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23037 ssc_tile_hei = ssc_tile_hei_buf;
23038 ssc_tile_hei_buf = -1;
23039 cursor_y += thei + MsgStrings[msgstr].vspace;
23040 if(bottom_margin_clip()) break;
23041 cursor_x=msg_margins[left];
23042 }
23043
23044 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
23045 upos, dpos, lpos, rpos);
23046
23047 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
23048 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
23049 return true;
23050 }
23051
23052 case MSGC_RUNMENU:
23053 {
23054 msg_menu_data[MNU_CHOSEN] = 0;
23055 msg_menu_data[MNU_CAN_CONFIRM] = 0;
23056 if(menu_options.size() < 1)
23057 return true;
23058 do_run_menu = true;
23059 return true;
23060 }
23061
23062 case MSGC_GOTOMENUCHOICE:
23063 {
23064 int32_t choice = grab_next_argument();
23065 if(msg_menu_data[MNU_CHOSEN] == choice)
23066 goto switched;
23067 (void)grab_next_argument();
23068 return true;
23069 }
23070
23071 case MSGC_ENDSTRING:
23072 {
23073 do_end_str = true;
23074 return true;
23075 }
23076 case MSGC_WAIT_ADVANCE:
23077 {
23078 wait_advance = true;
23079 linkedmsgclk = 51;
23080 return true;
23081 }
23082 case MSGC_TRIGSECRETS:
23083 {
23084 bool perm = (bool)grab_next_argument();
23085 hidden_entrance(0, true, false, -8);
23086 if(perm)
23087 setmapflag(mSECRET);
23088 return true;
23089 }
23090 case MSGC_SETSCREENSTATE:
23091 {
23092 int32_t flag = int32_t(grab_next_argument());
23093 if(unsigned(flag)>=mMAXIND)
23094 {
23095 Z_error("SCC 133: Flag %d is invalid\n", flag);
23096 return true;
23097 }
23098 bool state = bool(grab_next_argument());
23099 if(state)
23100 setmapflag(1<<flag);
23101 else
23102 unsetmapflag(1<<flag,true);
23103 return true;
23104 }
23105 case MSGC_SETSCREENSTATER:
23106 {
23107 int32_t map = (int32_t)grab_next_argument();
23108 int32_t scrid = (int32_t)grab_next_argument();
23109 if(map < 1 || map > map_count)
23110 {
23111 Z_error("SCC 134: Map %d is invalid\n", map);
23112 return true;
23113 }
23114 if(unsigned(scrid)>=0x80)
23115 {
23116 Z_error("SCC 134: Screen %d is invalid\n", scrid);
23117 return true;
23118 }
23119
23120 int32_t flag = int32_t(grab_next_argument());
23121 if(unsigned(flag)>=mMAXIND)
23122 {
23123 Z_error("SCC 134: Flag %d is invalid\n", flag);
23124 return true;
23125 }
23126 bool state = bool(grab_next_argument());
23127 if(state)
23128 setmapflag(mapind(map,scrid),1<<flag);
23129 else
23130 unsetmapflag(mapind(map,scrid),1<<flag,true);
23131 return true;
23132 }
23133 switched:
23134 int32_t lev = (int32_t)(grab_next_argument());
23135 if(lev && get_bit(quest_rules, qr_SCC_GOTO_RESPECTS_CONTFLAG)
23136 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
23137 {
23138 msgstr=lev;
23139 msgpos=msgptr=0;
23140 msgfont=setmsgfont();
23141 }
23142 else donewmsg(lev);
23143 msgptr--; // To counteract it being incremented after this routine is called.
23144 putprices(false);
23145 return true;
23146 }
23147
23148 54195 return false;
23149 55010 }
23150
23151 // Wraps the message string... probably.
23152 53590 void wrapmsgstr(char *s3)
23153 {
23154 53590 int32_t j=0;
23155
23156
2/2
✓ Branch 0 taken 9679 times.
✓ Branch 1 taken 43911 times.
53590 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
23157 {
23158
2/2
✓ Branch 0 taken 2081 times.
✓ Branch 1 taken 7598 times.
9679 if(msgspace)
23159 {
23160 2081 char c = MsgStrings[msgstr].s[msgptr];
23161
4/6
✓ Branch 0 taken 1786 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 1786 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1786 times.
✗ Branch 5 not taken.
2081 if(c != ' ' && c >= 32 && c <= 126)
23162 {
23163
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9806 times.
✓ Branch 2 taken 8026 times.
✓ Branch 3 taken 1786 times.
9812 for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++)
23164 {
23165
3/4
✓ Branch 0 taken 7734 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7734 times.
8026 if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k];
23166 8026 }
23167
23168 1786 s3[j] = 0;
23169 1786 msgspace = false;
23170 1786 }
23171 else
23172 {
23173 295 s3[0] = c;
23174 295 s3[1] = 0;
23175 }
23176 2081 }
23177 else
23178 {
23179 7598 s3[0] = MsgStrings[msgstr].s[msgptr];
23180 7598 s3[1] = 0;
23181
23182
2/2
✓ Branch 0 taken 5948 times.
✓ Branch 1 taken 1650 times.
7598 if(s3[0] == ' ') msgspace=true;
23183 }
23184 9679 }
23185 else
23186 {
23187 43911 s3[0] = MsgStrings[msgstr].s[msgptr];
23188 43911 s3[1] = 0;
23189 }
23190 53590 }
23191
23192 // Returns true if the pointer is at a string's
23193 // null terminator or a trailing space
23194 160259 bool atend(char const* str)
23195 {
23196 160259 int32_t i=0;
23197
23198
2/2
✓ Branch 0 taken 1399349 times.
✓ Branch 1 taken 160259 times.
1559608 while(str[i]==' ')
23199 1399349 i++;
23200
23201 160259 return str[i]=='\0';
23202 }
23203
23204 5989881 void putmsg()
23205 {
23206 5989881 bool oldmargin = get_bit(quest_rules, qr_OLD_STRING_EDITOR_MARGINS)!=0;
23207
2/2
✓ Branch 0 taken 5819142 times.
✓ Branch 1 taken 170739 times.
5989881 if(!msgorig) msgorig=msgstr;
23208
23209
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5989881 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5989881 if(wait_advance && linkedmsgclk < 1)
23210 linkedmsgclk = 1;
23211
2/2
✓ Branch 0 taken 5950207 times.
✓ Branch 1 taken 39674 times.
5989881 if(linkedmsgclk>0)
23212 {
23213
2/2
✓ Branch 0 taken 14273 times.
✓ Branch 1 taken 25401 times.
39674 if(linkedmsgclk==1)
23214 {
23215
5/6
✓ Branch 0 taken 14273 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13849 times.
✓ Branch 3 taken 424 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 13765 times.
14273 if(do_end_str||cAbtn()||cBbtn())
23216 {
23217 508 do_end_str = false;
23218 508 linkedmsgclk = 0;
23219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 508 times.
508 if(wait_advance)
23220 {
23221 wait_advance = false;
23222 }
23223 else
23224 {
23225 508 msgstr=MsgStrings[msgstr].nextstring;
23226
3/4
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 341 times.
✓ Branch 2 taken 167 times.
✗ Branch 3 not taken.
508 if(!msgstr && enqueued_str)
23227 {
23228 msgstr = enqueued_str;
23229 enqueued_str = 0;
23230 }
23231
2/2
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 167 times.
508 if(!msgstr)
23232 {
23233 167 msgfont=get_zc_font(font_zfont);
23234
23235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167 times.
167 if(tmpscr->room!=rGRUMBLE)
23236 167 blockpath=false;
23237
23238 167 dismissmsg();
23239 167 goto disappear;
23240 }
23241
23242 341 donewmsg(msgstr);
23243 341 putprices(false);
23244 }
23245 341 }
23246 14106 }
23247 else
23248 {
23249 25401 --linkedmsgclk;
23250 }
23251 39507 }
23252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5989714 times.
5989714 if(wait_advance) return; //Waiting for buttonpress
23253
23254
9/10
✓ Branch 0 taken 5989594 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 169791 times.
✓ Branch 3 taken 5819803 times.
✓ Branch 4 taken 109382 times.
✓ Branch 5 taken 60409 times.
✓ Branch 6 taken 53352 times.
✓ Branch 7 taken 56030 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 53352 times.
5989714 if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip()))
23255 {
23256
2/2
✓ Branch 0 taken 116439 times.
✓ Branch 1 taken 5819803 times.
5936242 if(!msgstr)
23257 5819803 msgorig=0;
23258
23259 5936242 msg_active = false;
23260 5936242 return;
23261 }
23262
23263 53472 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
23264
23265 char s3[145];
23266 int32_t tlength;
23267
23268 // Bypass the string with the B button!
23269
4/4
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 53151 times.
✓ Branch 2 taken 356 times.
✓ Branch 3 taken 52795 times.
53472 if(((cBbtn())&&(get_bit(quest_rules,qr_ALLOWMSGBYPASS))) || msgspeed==0)
23270 {
23271 //finish writing out the string
23272
4/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 36028 times.
✓ Branch 2 taken 557 times.
✓ Branch 3 taken 35500 times.
36177 while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr))
23273 {
23274
4/6
✓ Branch 0 taken 17002 times.
✓ Branch 1 taken 18498 times.
✓ Branch 2 taken 17002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17002 times.
✗ Branch 5 not taken.
35500 if(msgspeed && !(cBbtn() && get_bit(quest_rules,qr_ALLOWMSGBYPASS)))
23275 goto breakout; // break out if message speed was changed to non-zero
23276
4/6
✓ Branch 0 taken 35500 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35500 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 236 times.
✓ Branch 5 taken 35264 times.
35500 else if(!do_run_menu && !doing_name_insert && !parsemsgcode())
23277 {
23278
1/2
✓ Branch 0 taken 35264 times.
✗ Branch 1 not taken.
35264 if(bottom_margin_clip())
23279 break;
23280
23281 35264 wrapmsgstr(s3);
23282
23283
2/2
✓ Branch 0 taken 8522 times.
✓ Branch 1 taken 26742 times.
35264 if(MsgStrings[msgstr].s[msgptr]==' ')
23284 {
23285 8522 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
23286
23287
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 388 times.
8953 if(cursor_x+tlength > (msg_w-msg_margins[right])
23288
5/6
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 8091 times.
✓ Branch 2 taken 431 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 431 times.
✓ Branch 5 taken 43 times.
8522 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23289 43 ? true : strcmp(s3," ")!=0))
23290 {
23291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
474 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23292 388 ssc_tile_hei = ssc_tile_hei_buf;
23293 388 ssc_tile_hei_buf = -1;
23294 388 cursor_y += thei + MsgStrings[msgstr].vspace;
23295
1/2
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
388 if(bottom_margin_clip()) break;
23296 388 cursor_x=msg_margins[left];
23297 388 }
23298
23299 8522 char buf[2] = {0};
23300 8522 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
23301
23302 8522 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23303
23304 8522 cursor_x+=tlength;
23305 8522 }
23306 else
23307 {
23308 26742 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23309
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 356 times.
27266 if(cursor_x+tlength > (msg_w-msg_margins[right])
23310
5/6
✓ Branch 0 taken 567 times.
✓ Branch 1 taken 26175 times.
✓ Branch 2 taken 524 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 399 times.
✗ Branch 5 not taken.
26742 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23311 168 ? true : strcmp(s3," ")!=0))
23312 {
23313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 567 times.
567 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23314 567 ssc_tile_hei = ssc_tile_hei_buf;
23315 567 ssc_tile_hei_buf = -1;
23316 567 cursor_y += thei + MsgStrings[msgstr].vspace;
23317
1/2
✓ Branch 0 taken 567 times.
✗ Branch 1 not taken.
567 if(bottom_margin_clip()) break;
23318 567 cursor_x=msg_margins[left];
23319 567 }
23320
23321 26742 sfx(MsgStrings[msgstr].sfx);
23322
23323 26742 char buf[2] = {0};
23324 26742 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
23325
23326 26742 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23327
23328 26742 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
23329 26742 cursor_x += MsgStrings[msgstr].hspace;
23330 }
23331
23332 35264 msgpos++;
23333 35264 }
23334
1/2
✓ Branch 0 taken 35500 times.
✗ Branch 1 not taken.
35500 if(do_run_menu)
23335 {
23336 if(runMenuCursor())
23337 {
23338 do_run_menu = false;
23339 }
23340 else break;
23341 }
23342
1/2
✓ Branch 0 taken 35500 times.
✗ Branch 1 not taken.
35500 if(doing_name_insert)
23343 {
23344 if(*nameptr)
23345 {
23346 if(bottom_margin_clip())
23347 break;
23348
23349 char s3[9] = {0};
23350
23351 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
23352 {
23353 strcpy(s3, nameptr);
23354 }
23355 else
23356 {
23357 s3[0] = *nameptr;
23358 s3[1] = 0;
23359 }
23360
23361 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23362
23363 if(cursor_x+tlength > (msg_w-msg_margins[right])
23364 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23365 ? true : strcmp(s3," ")!=0))
23366 {
23367 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23368 ssc_tile_hei = ssc_tile_hei_buf;
23369 ssc_tile_hei_buf = -1;
23370 cursor_y += thei + MsgStrings[msgstr].vspace;
23371 if(bottom_margin_clip()) break;
23372 cursor_x=msg_margins[left];
23373 }
23374
23375 sfx(MsgStrings[msgstr].sfx);
23376
23377 char buf[2] = {0};
23378 sprintf(buf,"%c",*nameptr);
23379
23380 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23381
23382 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
23383 cursor_x += MsgStrings[msgstr].hspace;
23384 ++nameptr;
23385 continue; //don't advance the msgptr, as the next char in it was not processed!
23386 }
23387 else doing_name_insert = false;
23388 }
23389 35500 ++msgptr;
23390
1/2
✓ Branch 0 taken 35500 times.
✗ Branch 1 not taken.
35500 if(do_end_str)
23391 goto strendcheck;
23392
1/2
✓ Branch 0 taken 35500 times.
✗ Branch 1 not taken.
35500 if(wait_advance)
23393 return;
23394
2/2
✓ Branch 0 taken 34944 times.
✓ Branch 1 taken 556 times.
35500 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23395 {
23396
2/2
✓ Branch 0 taken 273 times.
✓ Branch 1 taken 283 times.
556 if(MsgStrings[msgstr].nextstring)
23397 {
23398
1/2
✓ Branch 0 taken 283 times.
✗ Branch 1 not taken.
283 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23399 {
23400 msgstr=MsgStrings[msgstr].nextstring;
23401 msgpos=msgptr=0;
23402 msgfont=setmsgfont();
23403 }
23404 283 }
23405 556 }
23406 }
23407
23408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 557 times.
557 if (!do_run_menu)
23409 {
23410 557 msgclk = 72;
23411 557 msgpos = 10000;
23412 557 }
23413 557 }
23414 else
23415 52795 {
23416 breakout:
23417
23418
6/6
✓ Branch 0 taken 43856 times.
✓ Branch 1 taken 8939 times.
✓ Branch 2 taken 14564 times.
✓ Branch 3 taken 29292 times.
✓ Branch 4 taken 9773 times.
✓ Branch 5 taken 4791 times.
52795 if(((msgclk++)%(msgspeed+1)<msgspeed)&&((!cAbtn())||(!get_bit(quest_rules,qr_ALLOWFASTMSG))))
23419 34083 return;
23420 }
23421
23422 // Start writing the string
23423
2/2
✓ Branch 0 taken 18716 times.
✓ Branch 1 taken 553 times.
19822 if(msgptr == 0)
23424 {
23425
2/2
✓ Branch 0 taken 553 times.
✓ Branch 1 taken 1101 times.
1654 while(MsgStrings[msgstr].s[msgptr]==' ')
23426 {
23427 1101 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
23428
23429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
1106 if(cursor_x+tlength > (msg_w-msg_margins[right])
23430
4/6
✓ Branch 0 taken 1096 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
1101 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23431 ? 1 : strcmp(s3," ")!=0))
23432 {
23433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23434 5 ssc_tile_hei = ssc_tile_hei_buf;
23435 5 ssc_tile_hei_buf = -1;
23436 5 cursor_y += thei + MsgStrings[msgstr].vspace;
23437
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(bottom_margin_clip()) break;
23438 5 cursor_x=msg_margins[left];
23439 5 }
23440
23441 1101 cursor_x+=tlength;
23442 1101 ++msgptr;
23443 1101 ++msgpos;
23444
23445 // The "Continue From Previous" feature
23446
2/2
✓ Branch 0 taken 1029 times.
✓ Branch 1 taken 72 times.
1101 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23447 {
23448
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(MsgStrings[msgstr].nextstring)
23449 {
23450 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23451 {
23452 msgstr=MsgStrings[msgstr].nextstring;
23453 msgpos=msgptr=0;
23454 msgfont=setmsgfont();
23455 }
23456 }
23457 72 }
23458 }
23459 553 }
23460
23461 reparsesinglechar:
23462 // Continue printing the string!
23463
3/4
✓ Branch 0 taken 18420 times.
✓ Branch 1 taken 849 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18420 times.
37689 if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip())
23464 {
23465
4/6
✓ Branch 0 taken 18420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 18326 times.
18420 if(!do_run_menu && !doing_name_insert && !parsemsgcode())
23466 {
23467 18326 wrapmsgstr(s3);
23468
23469 18326 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23470
23471
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 196 times.
18542 if(cursor_x+tlength > (msg_w-msg_margins[right])
23472
6/6
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 18106 times.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 196 times.
✓ Branch 5 taken 4 times.
18326 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23473 20 ? true : strcmp(s3," ")!=0))
23474 {
23475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23476 216 ssc_tile_hei = ssc_tile_hei_buf;
23477 216 ssc_tile_hei_buf = -1;
23478 216 cursor_y += thei + MsgStrings[msgstr].vspace;
23479
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(bottom_margin_clip()) goto strendcheck;
23480 216 cursor_x=msg_margins[left];
23481 //if(space) s3[0]=0;
23482 216 }
23483
23484 18326 sfx(MsgStrings[msgstr].sfx);
23485
23486 18326 char buf[2] = {0};
23487 18326 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
23488
23489 18326 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23490
23491 18326 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
23492 18326 cursor_x += MsgStrings[msgstr].hspace;
23493 18326 msgpos++;
23494 18326 }
23495
1/2
✓ Branch 0 taken 18420 times.
✗ Branch 1 not taken.
18420 if(do_end_str)
23496 goto strendcheck;
23497
1/2
✓ Branch 0 taken 18420 times.
✗ Branch 1 not taken.
18420 if(wait_advance)
23498 {
23499 ++msgptr;
23500 return;
23501 }
23502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18420 times.
18420 else if(do_run_menu)
23503 {
23504 if(runMenuCursor())
23505 {
23506 do_run_menu = false;
23507 ++msgptr;
23508 goto reparsesinglechar;
23509 }
23510 }
23511
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18420 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18420 else if(doing_name_insert && *nameptr)
23512 {
23513 char s3[9] = {0};
23514
23515 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
23516 {
23517 strcpy(s3, nameptr);
23518 }
23519 else
23520 {
23521 s3[0] = *nameptr;
23522 s3[1] = 0;
23523 }
23524
23525 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23526
23527 if(cursor_x+tlength > (msg_w-msg_margins[right])
23528 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23529 ? true : strcmp(s3," ")!=0))
23530 {
23531 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23532 ssc_tile_hei = ssc_tile_hei_buf;
23533 ssc_tile_hei_buf = -1;
23534 cursor_y += thei + MsgStrings[msgstr].vspace;
23535 if(bottom_margin_clip()) goto strendcheck;
23536 cursor_x=msg_margins[left];
23537 }
23538
23539 sfx(MsgStrings[msgstr].sfx);
23540
23541 char buf[2] = {0};
23542 sprintf(buf,"%c",*nameptr);
23543
23544 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23545
23546 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
23547 cursor_x += MsgStrings[msgstr].hspace;
23548 ++nameptr;
23549 }
23550 else
23551 {
23552 18420 doing_name_insert = false;
23553 18420 msgptr++;
23554
23555
2/2
✓ Branch 0 taken 17955 times.
✓ Branch 1 taken 465 times.
18420 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23556 {
23557
2/2
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 59 times.
465 if(MsgStrings[msgstr].nextstring)
23558 {
23559
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23560 {
23561 msgstr=MsgStrings[msgstr].nextstring;
23562 msgpos=msgptr=0;
23563 msgfont=setmsgfont();
23564 }
23565 59 }
23566 465 }
23567
23568
2/2
✓ Branch 0 taken 2697 times.
✓ Branch 1 taken 928 times.
22045 if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1)
23569
2/2
✓ Branch 0 taken 18380 times.
✓ Branch 1 taken 40 times.
18420 && (MsgStrings[msgstr].s[msgptr]==' ')
23570
2/2
✓ Branch 0 taken 3625 times.
✓ Branch 1 taken 14755 times.
18380 && (MsgStrings[msgstr].s[msgptr+1]==' '))
23571 {
23572
2/2
✓ Branch 0 taken 928 times.
✓ Branch 1 taken 31684 times.
32612 while(MsgStrings[msgstr].s[msgptr]==' ')
23573 {
23574 31684 msgspace = true;
23575 31684 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
23576
23577
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1392 times.
33099 if(cursor_x+tlength > (msg_w-msg_margins[right])
23578
4/6
✓ Branch 0 taken 1415 times.
✓ Branch 1 taken 30269 times.
✓ Branch 2 taken 1415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1392 times.
✗ Branch 5 not taken.
31684 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23579 23 ? true : strcmp(s3," ")!=0))
23580 {
23581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1415 times.
1415 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23582 1415 ssc_tile_hei = ssc_tile_hei_buf;
23583 1415 ssc_tile_hei_buf = -1;
23584 1415 cursor_y += thei + MsgStrings[msgstr].vspace;
23585
1/2
✓ Branch 0 taken 1415 times.
✗ Branch 1 not taken.
1415 if(bottom_margin_clip()) break;
23586 1415 cursor_x=msg_margins[left];
23587 1415 }
23588
23589 31684 cursor_x+=tlength;
23590 31684 ++msgpos;
23591 31684 ++msgptr;
23592
23593
2/2
✓ Branch 0 taken 2632 times.
✓ Branch 1 taken 29052 times.
31684 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23594 {
23595
2/2
✓ Branch 0 taken 25001 times.
✓ Branch 1 taken 4051 times.
29052 if(MsgStrings[msgstr].nextstring)
23596 {
23597
1/2
✓ Branch 0 taken 4051 times.
✗ Branch 1 not taken.
4051 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23598 {
23599 msgstr=MsgStrings[msgstr].nextstring;
23600 msgpos=msgptr=0;
23601 msgfont=setmsgfont();
23602 }
23603 4051 }
23604 29052 }
23605 }
23606 928 }
23607 }
23608 18420 }
23609 strendcheck:
23610 // Done printing the string
23611
10/14
✓ Branch 0 taken 19269 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19269 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19269 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18712 times.
✓ Branch 7 taken 557 times.
✓ Branch 8 taken 18257 times.
✓ Branch 9 taken 455 times.
✓ Branch 10 taken 18257 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 18179 times.
✓ Branch 13 taken 1090 times.
19269 if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk)
23612 {
23613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1090 times.
1090 if(!do_end_str)
23614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1090 times.
1090 while(parsemsgcode()); // Finish remaining control codes
23615
23616 // Go to next string, or make it disappear by going to string 0.
23617
5/6
✓ Branch 0 taken 748 times.
✓ Branch 1 taken 342 times.
✓ Branch 2 taken 581 times.
✓ Branch 3 taken 167 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 581 times.
1090 if(MsgStrings[msgstr].nextstring!=0 || get_bit(quest_rules,qr_MSGDISAPPEAR) || enqueued_str)
23618 {
23619 509 linkedmsgclk=do_end_str?1:51;
23620 509 }
23621
23622
2/2
✓ Branch 0 taken 748 times.
✓ Branch 1 taken 342 times.
1090 if(MsgStrings[msgstr].nextstring==0)
23623 {
23624
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 581 times.
748 if(!get_bit(quest_rules,qr_MSGDISAPPEAR))
23625 581 {
23626 disappear:
23627 748 msg_active = false;
23628 748 Hero.finishedmsg();
23629 748 }
23630
23631
2/2
✓ Branch 0 taken 903 times.
✓ Branch 1 taken 12 times.
915 if(repaircharge)
23632 {
23633 // if (get_bit(quest_rules,qr_REPAIRFIX)) {
23634 // fixed_door=true;
23635 // }
23636 12 game->change_drupy(-tmpscr[currscr<128?0:1].catchall);
23637 12 repaircharge = 0;
23638 12 }
23639
23640
2/2
✓ Branch 0 taken 914 times.
✓ Branch 1 taken 1 times.
915 if(adjustmagic)
23641 {
23642
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(get_bit(quest_rules,qr_OLD_HALF_MAGIC))
23643 {
23644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(game->get_magicdrainrate())
23645 1 game->set_magicdrainrate(1);
23646 1 }
23647 else if(game->get_magicdrainrate() > 1)
23648 {
23649 game->set_magicdrainrate(game->get_magicdrainrate()/2);
23650 }
23651 1 adjustmagic = false;
23652 1 sfx(WAV_SCALE);
23653
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
23654 1 }
23655
23656
2/2
✓ Branch 0 taken 914 times.
✓ Branch 1 taken 1 times.
915 if(learnslash)
23657 {
23658 1 game->set_canslash(1);
23659 1 learnslash = false;
23660 1 sfx(WAV_SCALE);
23661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
23662 1 }
23663 915 }
23664 1257 }
23665 5989761 }
23666
23667 14089 int32_t message_more_y()
23668 {
23669 //Is the flag ticked, do we really want a message more y larger than 160?
23670
5/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14075 times.
✓ Branch 2 taken 14089 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14075 times.
✓ Branch 5 taken 14 times.
14089 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
23671 14089 msgy+=playing_field_offset;
23672 14089 return msgy;
23673 }
23674
23675 /*** Collision detection & handling ***/
23676
23677 5967740 void clear_script_one_frame_conditions()
23678 {
23679
2/2
✓ Branch 0 taken 18370229 times.
✓ Branch 1 taken 5967740 times.
24337969 for(int32_t j=0; j<guys.Count(); j++)
23680 {
23681 18370229 enemy *e = (enemy*)guys.spr(j);
23682
2/2
✓ Branch 0 taken 293923664 times.
✓ Branch 1 taken 18370229 times.
312293893 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
23683 18370229 }
23684 5967740 }
23685
23686 5967655 void check_collisions()
23687 {
23688 5967655 bool temp_hit = false;
23689
2/2
✓ Branch 0 taken 2490939 times.
✓ Branch 1 taken 5967655 times.
8458594 for(int32_t i=0; i<Lwpns.Count(); i++)
23690 {
23691 2490939 weapon *w = (weapon*)Lwpns.spr(i);
23692
23693
8/8
✓ Branch 0 taken 2165482 times.
✓ Branch 1 taken 325457 times.
✓ Branch 2 taken 1810944 times.
✓ Branch 3 taken 354538 times.
✓ Branch 4 taken 1805835 times.
✓ Branch 5 taken 5109 times.
✓ Branch 6 taken 13640 times.
✓ Branch 7 taken 1792195 times.
2490939 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
23694 {
23695
2/2
✓ Branch 0 taken 1782592 times.
✓ Branch 1 taken 6346687 times.
8129279 for(int32_t j=0; j<guys.Count(); j++)
23696 {
23697 6346687 enemy *e = (enemy*)guys.spr(j);
23698
2/2
✓ Branch 0 taken 57885 times.
✓ Branch 1 taken 6288802 times.
6346687 if ( !temp_hit ) e->hitby[HIT_BY_LWEAPON] = 0;
23699
23700
2/2
✓ Branch 0 taken 6229110 times.
✓ Branch 1 taken 117577 times.
6346687 if(e->hit(w)) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
23701 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
23702 {
23703 // !(e->stunclk)
23704 117577 int32_t h = e->takehit(w);
23705
2/2
✓ Branch 0 taken 97455 times.
✓ Branch 1 taken 20122 times.
117577 if (h == -1)
23706 {
23707 20122 e->hitby[HIT_BY_LWEAPON] = i+1; temp_hit = true;
23708 20122 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
23709 //e->hitby[HIT_BY_LWEAPON_FAMILY] = itemsbuf[w->parentid].family; //that would be the itemclass, not the weapon type!
23710 20122 e->hitby[HIT_BY_LWEAPON_FAMILY] = w->id;
23711 //al_trace("npc->HitBy[] Parent Item is: %d /n", w->parentitem);
23712 //al_trace("npc->HitBy[] Parent ID is: %d /n", w->parentid);
23713 20122 e->hitby[HIT_BY_LWEAPON_LITERAL_ID] = w->parentitem;
23714
23715 20122 }
23716 //we may need to handle this in special cases. -Z
23717
23718 //if h == stun or ignore
23719
23720 //if e->stun > DEFAULT_STUN -1 || !e->stun
23721 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
23722 ///! how about: if w->dead != bounce !
23723
23724 // NOT FOR PUBLIC RELEASE
23725 /*if(h==3) //Mirror shield
23726 {
23727 if (w->id==ewFireball || w->id==wRefFireball)
23728 {
23729 w->id=wRefFireball;
23730 switch(e->dir)
23731 {
23732 case up: e->angle += (PI - e->angle) * 2.0; break;
23733 case down: e->angle = -e->angle; break;
23734 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
23735 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
23736 // TODO: the following. -L.
23737 case l_up: break;
23738 case r_up: break;
23739 case l_down: break;
23740 case r_down: break;
23741 }
23742 }
23743 else
23744 {
23745 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
23746 w->dir ^= 1;
23747 if(w->dir&2)
23748 w->flip ^= 1;
23749 else
23750 w->flip ^= 2;
23751 }
23752 w->ignoreHero=false;
23753 }
23754 else*/
23755
2/2
✓ Branch 0 taken 91071 times.
✓ Branch 1 taken 26506 times.
117577 if(h)
23756 {
23757
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26506 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26506 if(e->switch_hooked && w->family_class == itype_switchhook)
23758 w->onhit(false, e, -1);
23759 26506 else w->onhit(false, e, h);
23760 26506 }
23761
23762
2/2
✓ Branch 0 taken 115308 times.
✓ Branch 1 taken 2269 times.
117577 if(h==2)
23763 {
23764 2269 break;
23765 }
23766 115308 }
23767
23768
2/2
✓ Branch 0 taken 6337084 times.
✓ Branch 1 taken 7334 times.
6344418 if(w->Dead())
23769 {
23770 7334 break;
23771 }
23772 6337084 }
23773
23774 // Item flags added in 2.55:
23775 // BRang/HShot/Arrows ITEM_FLAG4 is "Pick up anything" (port of qr_BRANGPICKUP)
23776 // BRang/HShot ITEM_FLAG5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
23777 // Arrows ITEM_FLAG2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
23778 // -V
23779
6/6
✓ Branch 0 taken 1514438 times.
✓ Branch 1 taken 277757 times.
✓ Branch 2 taken 1510008 times.
✓ Branch 3 taken 4430 times.
✓ Branch 4 taken 13738 times.
✓ Branch 5 taken 1496270 times.
1792195 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
23780 {
23781 295925 int32_t itype, pitem = w->parentitem;
23782
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 277757 times.
✓ Branch 2 taken 13738 times.
✓ Branch 3 taken 4430 times.
295925 switch(w->id)
23783 {
23784 277757 case wBrang: itype = itype_brang; break;
23785 13738 case wArrow: itype = itype_arrow; break;
23786 case wHookshot:
23787 4430 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
23788 4430 break;
23789 }
23790
2/2
✓ Branch 0 taken 294760 times.
✓ Branch 1 taken 1165 times.
295925 if(pitem < 0) pitem = current_item_id(itype);
23791
5/6
✓ Branch 0 taken 4430 times.
✓ Branch 1 taken 291495 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 4330 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
295925 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & ITEM_FLAG9))
23792 { //Swap with item
23793 for(int32_t j=0; j<items.Count(); j++)
23794 {
23795 if(items.spr(j)->hit(w))
23796 {
23797 item *theItem = ((item*)items.spr(j));
23798 bool priced = theItem->PriceIndex >-1;
23799 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
23800 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
23801 || (((itemsbuf[w->parentitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
23802 {
23803 if(!Hero.switchhookclk)
23804 {
23805 hooked_combopos = -1;
23806 hooked_layerbits = 0;
23807 switching_object = theItem;
23808 theItem->switch_hooked = true;
23809 w->misc = 2;
23810 w->step = 0;
23811 theItem->clk2=256;
23812 Hero.doSwitchHook(game->get_switchhookstyle());
23813 if(QMisc.miscsfx[sfxSWITCHED])
23814 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
23815 }
23816 }
23817 }
23818 }
23819 }
23820
6/6
✓ Branch 0 taken 13738 times.
✓ Branch 1 taken 282187 times.
✓ Branch 2 taken 278771 times.
✓ Branch 3 taken 265033 times.
✓ Branch 4 taken 282187 times.
✓ Branch 5 taken 265033 times.
295925 else if((w->id==wArrow&&itemsbuf[pitem].flags & ITEM_FLAG2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & ITEM_FLAG5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
23821 {
23822
2/2
✓ Branch 0 taken 65248 times.
✓ Branch 1 taken 278771 times.
344019 for(int32_t j=0; j<items.Count(); j++)
23823 {
23824
2/2
✓ Branch 0 taken 61479 times.
✓ Branch 1 taken 3769 times.
65248 if(items.spr(j)->hit(w))
23825 {
23826 3769 item *theItem = ((item*)items.spr(j));
23827 3769 bool priced = theItem->PriceIndex >-1;
23828
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 3746 times.
3769 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
23829
5/8
✓ Branch 0 taken 3769 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3769 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3086 times.
✓ Branch 5 taken 683 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1686 times.
5455 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
23830
4/6
✓ Branch 0 taken 2369 times.
✓ Branch 1 taken 1686 times.
✓ Branch 2 taken 2369 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2369 times.
3769 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey))&& !priced)))
23831 {
23832
1/2
✓ Branch 0 taken 1400 times.
✗ Branch 1 not taken.
4772 if(itemsbuf[theItem->id].collect_script)
23833 {
23834 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
23835 }
23836
23837 1400 Hero.checkitems(j);
23838 1400 }
23839 3769 }
23840 65248 }
23841 278771 }
23842
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 15966 times.
547220 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
23843 {
23844
2/2
✓ Branch 0 taken 3334 times.
✓ Branch 1 taken 15966 times.
19300 for(int32_t j=0; j<items.Count(); j++)
23845 {
23846
2/2
✓ Branch 0 taken 2399 times.
✓ Branch 1 taken 935 times.
3334 if(items.spr(j)->hit(w))
23847 {
23848 935 item *theItem = ((item*)items.spr(j));
23849 935 bool priced = theItem->PriceIndex >-1;
23850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 935 times.
935 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
23851
4/6
✓ Branch 0 taken 935 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 935 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 895 times.
✓ Branch 5 taken 40 times.
935 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
23852
5/10
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 376 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 376 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
935 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
23853 {
23854 559 int32_t pickup = theItem->pickup;
23855 559 int32_t id2 = theItem->id;
23856 559 int32_t pstr = theItem->pstring;
23857 559 int32_t pstr_flags = theItem->pickup_string_flags;
23858
23859 559 std::vector<int32_t> &ev = FFCore.eventData;
23860 559 ev.clear();
23861 559 ev.push_back(id2*10000);
23862 559 ev.push_back(pickup*10000);
23863 559 ev.push_back(pstr*10000);
23864 559 ev.push_back(pstr_flags*10000);
23865 559 ev.push_back(0);
23866 559 ev.push_back(theItem->getUID());
23867 559 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
23868 559 ev.push_back(w->getUID());
23869
23870 559 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
23871 559 bool nullify = ev[4] != 0;
23872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(nullify) continue;
23873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(w->id == wBrang)
23874 {
23875 559 w->onhit(false);
23876 559 }
23877
23878
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 37 times.
559 if(w->dragging==-1)
23879 {
23880 37 w->dead=1;
23881 37 theItem->clk2=256;
23882 37 w->dragging=j;
23883 37 theItem->is_dragged = true;
23884 37 }
23885 559 }
23886 935 }
23887 3334 }
23888 15966 }
23889 295925 }
23890 1792195 }
23891 2490939 }
23892 5967655 }
23893
23894 5967740 void dragging_item()
23895 {
23896
2/2
✓ Branch 0 taken 2533922 times.
✓ Branch 1 taken 5967740 times.
8501662 for(int32_t i=0; i<Lwpns.Count(); i++)
23897 {
23898 2533922 weapon *w = (weapon*)Lwpns.spr(i);
23899
23900
4/4
✓ Branch 0 taken 2250277 times.
✓ Branch 1 taken 283645 times.
✓ Branch 2 taken 2517615 times.
✓ Branch 3 taken 16307 times.
2533922 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & ITEM_FLAG5)//ITEM_FLAG5 is a port for qr_Z3BRANG_HSHOT
23901 {
23902
3/4
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 15756 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 551 times.
16307 if(w->dragging>=0 && w->dragging<items.Count())
23903 {
23904 551 item* dragItem = (item*)items.spr(w->dragging);
23905 551 dragItem->x=w->x;
23906 551 dragItem->y=w->y;
23907
23908 // Drag the Fairy enemy as well as the Fairy item
23909 551 int32_t id = dragItem->id;
23910
23911
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 551 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
551 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
23912 {
23913 movefairynew2(w->x,w->y,*dragItem);
23914 }
23915 551 }
23916 16307 }
23917 2533922 }
23918 5967740 }
23919
23920 20 int32_t more_carried_items()
23921 {
23922 20 int32_t hasmorecarries = 0;
23923
23924
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 20 times.
42 for(int32_t i=0; i<items.Count(); i++)
23925 {
23926
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 20 times.
22 if(((item*)items.spr(i))->pickup & ipENEMY)
23927 {
23928 20 hasmorecarries++;
23929 20 }
23930 22 }
23931
23932 20 return hasmorecarries;
23933 }
23934
23935 // messy code to do the enemy-carrying-the-item thing
23936 5967740 void roaming_item()
23937 {
23938
4/4
✓ Branch 0 taken 9588 times.
✓ Branch 1 taken 5958152 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 9566 times.
5967740 if(!(hasitem&(4|2)) || !loaded_enemies)
23939 5958174 return;
23940
23941 // All enemies already dead upon entering a room?
23942
1/2
✓ Branch 0 taken 9566 times.
✗ Branch 1 not taken.
9566 if(guys.Count()==0)
23943 {
23944 return;
23945 }
23946
23947 // Lost track of the carrier?
23948
4/6
✓ Branch 0 taken 9566 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9566 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9561 times.
✓ Branch 5 taken 5 times.
9566 if(guycarryingitem<0 || guycarryingitem>=guys.Count() ||
23949 9566 !((enemy*)guys.spr(guycarryingitem))->itemguy)
23950 {
23951 5 guycarryingitem=-1;
23952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 for(int32_t j=0; j<guys.Count(); j++)
23953 {
23954
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5 times.
19 if(((enemy*)guys.spr(j))->itemguy)
23955 {
23956 5 guycarryingitem=j;
23957 5 break;
23958 }
23959 14 }
23960 5 }
23961
23962
2/2
✓ Branch 0 taken 9545 times.
✓ Branch 1 taken 21 times.
9566 if(hasitem&4)
23963 {
23964 21 guycarryingitem = -1;
23965
23966
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 21 times.
189 for(int32_t i=0; i<guys.Count(); i++)
23967 {
23968
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 21 times.
168 if(((enemy*)guys.spr(i))->itemguy)
23969 {
23970 21 guycarryingitem = i;
23971 21 }
23972 168 }
23973
23974
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(guycarryingitem == -1) //This happens when "default enemies" such as
23975 {
23976 return; //eSHOOTFBALL are alive but enemies from the list
23977 } //are not. Defer to HeroClass::checkspecial().
23978
23979 21 int32_t Item=tmpscr->item;
23980
23981 21 hasitem &= ~4;
23982
23983
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
23984 {
23985 39 additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE
23986
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 18 times.
21 + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
23987 );
23988 21 hasitem |= 2;
23989 21 }
23990 else
23991 {
23992 return;
23993 }
23994 21 }
23995
23996
2/2
✓ Branch 0 taken 10080 times.
✓ Branch 1 taken 9566 times.
19646 for(int32_t i=0; i<items.Count(); i++)
23997 {
23998
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 9566 times.
10080 if(((item*)items.spr(i))->pickup&ipENEMY)
23999 {
24000
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 7221 times.
9566 if(get_bit(quest_rules,qr_HIDECARRIEDITEMS))
24001 {
24002 7221 items.spr(i)->x = -128; // Awfully inelegant, innit?
24003 7221 items.spr(i)->y = -128;
24004 7221 }
24005
2/4
✓ Branch 0 taken 2345 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2345 times.
2345 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
24006 {
24007
1/2
✓ Branch 0 taken 2345 times.
✗ Branch 1 not taken.
2345 if (!get_bit(quest_rules, qr_BROKEN_ITEM_CARRYING))
24008 {
24009 if (get_bit(quest_rules, qr_ENEMY_DROPS_USE_HITOFFSETS))
24010 {
24011 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hxsz/2)-8;
24012 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hysz/2)-10;
24013 }
24014 else
24015 {
24016 if(guys.spr(guycarryingitem)->extend >= 3)
24017 {
24018 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
24019 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
24020 }
24021 else
24022 {
24023 items.spr(i)->x = guys.spr(guycarryingitem)->x;
24024 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
24025 }
24026 }
24027 items.spr(i)->z = guys.spr(guycarryingitem)->z;
24028 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
24029 }
24030 else
24031 {
24032 2345 items.spr(i)->x = guys.spr(guycarryingitem)->x;
24033 2345 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
24034 2345 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
24035 }
24036 2345 }
24037 9566 }
24038 10080 }
24039 5967740 }
24040
24041 bool enemy::IsBigAnim()
24042 {
24043 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
24044 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
24045 || anim == a4FRM8DIRB);
24046 }
24047
24048 const char *old_guy_string[OLDMAXGUYS] =
24049 {
24050 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
24051 // 020
24052 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
24053 // 025
24054 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
24055 // 030
24056 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
24057 // 035
24058 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
24059 // 040
24060 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
24061 // 045
24062 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
24063 // 050
24064 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
24065 // 055
24066 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
24067 // 060
24068 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
24069 // 065
24070 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
24071 // 070
24072 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
24073 // 075
24074 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
24075 // 080
24076 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
24077 // 085
24078 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
24079 // 090
24080 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
24081 // 095
24082 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
24083 // 100
24084 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
24085 // 105
24086 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
24087 // 110
24088 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
24089 // 115
24090 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
24091 // 120
24092 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
24093 // 125
24094 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
24095 // 130
24096 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
24097 // 135
24098 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
24099 // 140
24100 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
24101 // 145
24102 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
24103 // 150
24104 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
24105 // 155
24106 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
24107 // 160
24108 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
24109 // 165
24110 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
24111 // 170
24112 "Pols Voice (Magic) ", "Pols Voice (Whistle) ", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
24113 // 175
24114 "Grappler Bug (HP) ", "Grappler Bug (MP) "
24115 };
24116
24117 /*** end of guys.cc ***/
24118
24119